Dynapi
A powerful WYSIWYG routes generator
Links
Features
Create a dynamic generating API server according to your directory structure, with your favorite front-end frameworks and amazing features we provided.
- Directory structure based routing
- Powerful flow control (using
throw
andnext(props)
) - ESNext support
- Customizable transform plugins
- Complex parameter support (e.g.
/flights/:from-:to
and you can specify patterns of:from
and:to
, or custom validator) - Customizable middleware prefixes
- More builders (
JavaScript
,TypeScript
,CoffeeScript
, etc.)
How it works
First, we use file watcher to track changes of files and record which file was imported from the target, then transform the files into executable Nodejs module.
Of course it's not all, we create a router according to filename
and dirname
, then generate
middleware chains to handle different requests.
Getting started
npm install dynapi
Set up your server application like: (Install connect
or express
in your consider)
server/index.js
const express = // or 'connect'const dynapi = const app = app app
After that, populate ./server/api/get.js
inside your project:
server/api/get.js
{ // If you're using express if resjson res else const body = JSON resstatusCode = 200 res res res }
And then start your server:
node server/index.js
Open page in browser http://localhost:3000/api
or Execute command curl -v http://localhost:3000/api
or Use requesting tools like Postman: