This is a CSS-based backend framework that compiles CSS syntax into an Express.js server.
CSS Server allows developers to write server logic (HTTP routing, SQL queries, conditionals) using CSS syntax. The system parses CSS files with PostCSS and compiles them into a working Express.js server with SQLite database support.
Read these docs first:
docs/ARCHITECTURE.md- System design and data flowdocs/REQUIREMENTS.md- Functional requirementsdocs/SYNTAX.md- Complete CSS syntax reference
pnpm build # Compile TypeScript to dist/
pnpm test # Run all tests with vitest
pnpm start -- ./examples/crud.css # Run server with CSS file- PostCSS for CSS parsing (not Puppeteer)
- pnpm as package manager (not npm)
- better-sqlite3 for SQLite (synchronous API)
- Express.js as the HTTP server runtime
[path='/users/:id']:get {
}- Use
[path="..."]selector for routes - Use
:GET,:POST,:PUT,:DELETEpseudo-classes for HTTP methods - URL parameters use Express syntax:
:id,:name, etc.
--varName: value;- Variables use
--prefix (CSS custom property style) - Reference with
var(--varName)
param(:name)- URL parameterquery(name)- Query string parameterbody()- Request body (JSON)header(name)- Request headersql("query", args...)- SQL query executionvar(--name)- Variable referenceif(--var: value; else: default)- Conditional expression
@database {
CREATE TABLE users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT,
email TEXT
);
}@return json(...);
@return html(...);- No comments unless explicitly instructed
- Full TypeScript type inference (no explicit generics when inferable)
- Minimal, direct implementations
- No
anytypes
- Tests use vitest framework
- Integration tests use supertest for HTTP requests
- Each test file creates isolated SQLite databases to avoid conflicts
- Run tests after making changes:
pnpm test
better-sqlite3may need rebuild:pnpm rebuild better-sqlite3- Use unique database filenames for parallel tests
src/
├── types.ts # All TypeScript interfaces
├── parser.ts # PostCSS parsing → AST
├── evaluator.ts # Expression evaluation
├── compiler.ts # AST → Express handlers
├── runtime.ts # Server creation/startup
└── index.ts # CLI entry point
tests/
├── parser.test.ts
├── evaluator.test.ts
└── integration.test.ts
- Update
types.tsif new interfaces needed - Update
parser.tsif new CSS syntax - Update
evaluator.tsif new expressions - Update
compiler.tsif new route handling - Add tests for new functionality
- Update
docs/SYNTAX.mdif syntax changes