Package Exports
- easy-api-path
- easy-api-path/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (easy-api-path) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Create API URLs or Endpoints for NodeJS application without create custom router
Installation
Install "easy-api-path" with npm
npm install easy-api-path
Install "easy-api-path" with yarn
yarn add easy-api-path
Usage/Examples
Create controllers inside "controllers" directory
// import package "easy-api-path"
const apiPath = require('easy-api-path');
// import your main app
const {app} = require('../../../../app');
// Don't use express.Router()
// Don't need to write custom path, eg: "/api/v1/create/user"
// create a route path by using "apiPath(__filename)"
// "apiPath(__filename)" generate same "/api/v1/create/user"
app.post(apiPath(__filename), (req, res) => {
// your custom code...
res.send(`WOW, It's working...`);
});
Tech Stack
Server: Node, Express