https://github.com/vriskaserket51/common-api
Simple Backend framework with JWT and MySQL support
https://github.com/vriskaserket51/common-api
backend-api framework jwt mysql
Last synced: 2 months ago
JSON representation
Simple Backend framework with JWT and MySQL support
- Host: GitHub
- URL: https://github.com/vriskaserket51/common-api
- Owner: VriskaSerket51
- License: gpl-3.0
- Created: 2023-01-22T09:38:43.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-15T17:44:00.000Z (over 1 year ago)
- Last Synced: 2025-03-28T04:35:59.842Z (2 months ago)
- Topics: backend-api, framework, jwt, mysql
- Language: TypeScript
- Homepage: https://npmjs.com/package/@ireves/common-api
- Size: 155 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# common-api
Simple backend framework with JWT and MySQL support.
## Installation into an existing project
To install `common-api` as a dependency of your Node.js project:
```sh
npm install @ireves/common-api
````common-api` is made with TypeScript.
## How to use
```javascript
import CommonApi from "@ireves/common-api";
import path from "path";CommonApi.initializeConfig(config);
CommonApi.initializeScheduler(schedules);runExpressApp();
function runExpressApp() {
const app = new CommonApi.App(
path.join(__dirname, "router"),
[],
CommonApi.defaultRouterMiddlewares,
[]
);
app.run(
config.port,
() => {
console.info(`Server started with port: ${config.port}`);
},
(error) => {
CommonApi.logger.error(error);
}
);
}
``````javascript
const config: CommonApi.Config = {
jwtSecret: "secret",
db: {
host: "127.0.0.1",
port: 3306,
user: "root",
password: "password",
database: "db",
},
};
``````javascript
const schedules: CommonApi.Schedule[] = [
name: "testSchedule",
cron: "00 00 00 * * *",
job: () => {
console.log("Welcome!")
},
];
```