-
Notifications
You must be signed in to change notification settings - Fork 0
Installation
Follow these steps to install and set up Simple API Router in your project.
Before installing, make sure you have:
To install Simple API Router, run:
npm install @notnexx/n-sar
yarn add @notnexx/n-sar
If you already have an Express project, you can use @notnexx/n-sar
to automatically load all routes from the api/
directory.
const express = require('express');
const loadRoutes = require('@notnexx/n-sar');
const app = express();
const PORT = 3000;
app.use(express.json());
loadRoutes(app);
app.listen(PORT, () => {
console.log(`Server running at http://localhost:${PORT}`);
});
To quickly generate a new API project with a predefined structure, use:
npx n-sar create my-api-project
This creates a new project folder my-api-project
with the following structure:
my-api-project/
βββ api/
β βββ router.js
β βββ user.js
βββ package.json
βββ server.js
Then, install dependencies and start the server:
cd my-api-project
npm install
node server.js
Your API server will now run at http://localhost:3000
.
To check if Simple API Router is installed correctly, run:
npm list @notnexx/n-sar
or
yarn list @notnexx/n-sar
If the package appears in the list, the installation was successful.
-
Learn how to [generate an API client](../API-Client).
-
Join our [community discussions](../Discussions) for support and feedback.
π‘ Need help? Feel free to [open an issue](../issues) or start a [discussion](../discussions).