express-instant
v1.1.0
Published
Instant Express — JSON-configured Express server with auth, CRUD templates, WebSockets, and custom handlers.
Maintainers
Readme
Instant Express
Brand: Instant Express · npm: express-instant
JSON-configured Express server — define routes, auth, CRUD, and custom handlers in one config file. Ship a REST API without boilerplate.
Live demo: express-instant.vercel.app
Why this exists
| Tool | What it does | |------|----------------| | JSON Server | Mock API from a data JSON file | | PocketBase | Full backend platform with admin UI | | Instant Express | Route config JSON + templates + escape hatches — you stay on Express |
Not a game backend (Nakama). Not a mock server. A composable library for real small APIs.
Install
npm install express-instantQuick start (CLI)
cp slices.example.json my-api.json
cp .env.example .env
npx express-instant --config-file my-api.jsonOr add to package.json:
{
"scripts": {
"start": "express-instant --config-file my-api.json"
}
}Quick start (library)
import { createApp, loadConfigFromFile } from "express-instant";
const config = loadConfigFromFile("./my-api.json");
const app = await createApp(config);
app.listen(3000);Example config — Todo API with auth
{
"port": 3000,
"dotenv": true,
"cors": true,
"mongoDB": true,
"bodyParser": { "json": true },
"routes": {
"/health": { "GET": { "type": "template", "template": "health" } },
"/auth/sign-up": { "POST": { "type": "template", "template": "signUp" } },
"/auth/sign-in": { "POST": { "type": "template", "template": "signIn" } },
"/items/:collection": {
"GET": { "type": "template", "template": "listItems" },
"POST": {
"type": "template",
"template": "listItems",
"middleware": ["requireAuth"]
}
}
}
}See slices.example.json for the full copy-paste example.
Route types
| Type | Description |
|------|-------------|
| template | Built-in handler (health, signUp, signIn, listItems) |
| function | Inline handler string |
| module | Load a local .js module |
| import | Import ES module handler |
| static | Serve static files |
| routes | Nested router |
Middleware on routes
{
"POST": {
"type": "template",
"template": "listItems",
"middleware": ["requireAuth"]
}
}Built-in templates
| Template | Description |
|----------|-------------|
| health | { success, status, uptime } |
| signUp | Register user → MongoDB + bcrypt + JWT |
| signIn | Login → JWT |
| listItems | In-memory CRUD on /items/:collection |
| mongoItems | MongoDB CRUD on /db/:collection (requires mongoDB: true) |
WebSockets
{
"websockets": {
"/ws": { "template": "echo" }
}
}Built-in echo template sends { type: "connected" } on connect and echoes messages back.
Built-in middleware
| Middleware | Description |
|------------|-------------|
| requireAuth | Validates Authorization: Bearer <jwt> |
Extend the library
import { registerTemplate, registerMiddleware } from "express-instant";
registerTemplate("myHandler", (req, res) => res.json({ ok: true }));
registerMiddleware("adminOnly", (req, res, next) => { /* ... */ next(); });Environment variables
MONGODB_STRING=mongodb://localhost:27017
MONGODB_NAME=express-instant
JWT_SECRET=change-me-in-production
EXPRESS_INSTANT_CONFIG=./my-api.json
PORT=3000Development
git clone https://github.com/m3yevn/express-instant.git
cd express-instant
npm install
npm run dev
npm testLicense
MIT © Kevin Moe Myint Myat
