Skip to content

Instantly share code, notes, and snippets.

@trapcodeio
Last active November 19, 2021 14:13
Show Gist options
  • Save trapcodeio/ed96d06e94e7d27c4e75533c204e09a7 to your computer and use it in GitHub Desktop.
Save trapcodeio/ed96d06e94e7d27c4e75533c204e09a7 to your computer and use it in GitHub Desktop.
Spin Xpresser
/**
* --- STAGE: RFC ---
* Xpresser Spin is a one file xpresser setup command.
* This will become the fastest way to spin up an expressjs fully backed MVC server in nodejs.
* @example
* xjs spin app.ts // will read the file and start xpresser.
*/
// For types sake
type DollarSign = any;
type XpresserRouter = any;
type Http = any;
// The only required function.
export function xpresser($: DollarSign) {
// Set custom config.
$.config.set({
name: "My App"
});
// Return xpresser
return $;
}
// similar to routes file with option for regular route file.
export function routes(router: XpresserRouter) {
router.get("/", "Hello World!");
router.get("/about", (http: Http) => http.json({ message: `I am unique` }));
return router;
}
// Similar to plugins.json
export function plugins() {
return { "npm://@xpresser/jwt": true };
}
// Similar to use.json
export function use() {
return {
extends: {
RequestEngine: "backend://RequestEngine"
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment