0.1.0 • Published 4 years ago
fspress v0.1.0
fspress - FileSystem driven ExpressJS WIP
fspress is a small library for quickly creating ExpressJS backends that uses filesystem paths for route definitions. Inspired from cli-api-mocker
- Zero boilerplate
- Very easy to create REST APIs
- Simple REST API mocks with proxy support
- Easyly create template driven websites
Installation
Install fspress globally with
npm i -g fspressUsage
Create your routes with a folder structure like:
messages
\_ :messageId
| \_ GET.json
| \_ GET.html
\_ POST.js
\_ GET.js
\_ GET.html
index.htmlIf you run flash command in main folder of this project;
GET localhost:3000/request (withAccept: text/htmlheader) will return rendered result of./index.htmlGET localhost:3000/messages/23123request (withAccept: text/htmlheader) will return rendered result of./messages/:messageId/GET.htmlGET localhost:3000/messages/53242request (withAccept: application/jsonheader) will return content of./messages/:messageId/GET.jsonPOST localhost:3000/messagesrequest will be responded by express middleware exported in./messages/POST.js.
Example:
module.exports = (req, res) => {
res.json({message: "Hello World!"});
}Main schema is [METHOD] localhost:3000/[PATH] goes to file {BASEPATH}[PATH]/[METHOD].(js|json|html|xml|png|...) Correct file type to respond request will be decided regarding to Accept request header.
More information will come...
0.1.0
4 years ago