
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Node API Maker built with polka and nodejs
The idea is to make API development quick and easy. Every single end point is handled by one file that called service. One service include:
Install Napim CLI globally (optional)
npm install -g napim-cli
you can check by running napim --version
Generate Napim template (optional)
napim init project-name
change project name with your actual project name
for typescript support, ad -ts in the end eg:napim init project-name -ts
Install dependency
cd project-name && npm install
Update Napim to current version
npm install napim
This is default folder structur for typescript mode:
.
|-- dist //compiled script will be here
|-- log //all error log will be here
|-- src
|-- middleware
|-- model
|-- service
|-- stub //napim template generator, edit the template to match your needs
|-- middleware.napim
|-- model.napim
|-- service.napim
index.ts //your main js file
|-- .env
|-- .gitignore
|-- knexfile.js // by defaut napim use knex for Database Query Builder, delete it if you use nosql like mongo
|-- package.json
|-- router.json //this file will map your API endpoint to execute service file
|-- tsconfig.json
Generate Service
napim make:service service-name
by default service have method GET, you can change by append the method argument in the end, eg:
napim make:service login --post
this command will create file login_post.ts in service folder and append route data to router.json with tag: "default" inside post array, just check it :)
By default, prefix for default tag is api, so you can execute the service by access endpoint POST:[host]/api/login
If you want to add some tag, for example secure (You can add middleware like Auth later), add tag argument
napim make:service users --tag=secure
You can also make dynamic endpoint, for example find user by some id
napim make:service users/:id
Generate Model
If you use Model like Objection.js to you can generate Objection model by
napim make:model ModelName
if you prefer to use raw query, just import {db} from "napim" and use it like db.query(trx)... see knex documentation for detail
If you want to use db transaction, just change transaction to true in your service file, ez
You like NoSQL like mongo, just edit your .env add DB_DRIVER=mongo and create your own Model or Schema and import to your service like usually
TODO: implement db transaction for mongo
Generate Middleware
Want to make Auth, JWT, or handle uploaded file (eg: using multer) you can create it in middleware
napim make:middleware JWT
then use it in router, append it in middleware array for example:
//router.json
[
{
"tag": "default",
"prefix": "/api",
"middleware": [],
"get": [],
"post": [
{
"path": "/login",
"service": "/login_post"
}
]
},
{
"tag": "secure",
"prefix": "/api/secure",
"middleware": [
"JWT"
],
"get": [
{
"path": "/products/:id",
"service": "/products/_id_get"
}
]
},
{
"tag": "admin",
"prefix": "/api/admin",
"middleware": [
"JWT",
"Admin"
],
"get": [
{
"path": "/products",
"service": "/products_get"
}
],
"post": [
{
"path": "/products",
"service": "/products_post"
}
],
"delete": [
{
"path": "/products/:id",
"service": "/producst/_id_delete"
}
],
"patch": [
{
"path": "/products/:id",
"service": "/producst/_id_patch"
}
]
}
]
If you want to access polka instance, just import {app} from "napim"
FAQs
Node Api Maker build with polka
We found that napim-next demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.