Skip to content

VriskaSerket51/common-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

npm install @ireves/common-api

common-api is made with TypeScript.

How to use

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);
        }
    );
}
const config: CommonApi.Config = {
    jwtSecret: "secret",
    db: {
        host: "127.0.0.1",
        port: 3306,
        user: "root",
        password: "password",
        database: "db",
    },
};
const schedules: CommonApi.Schedule[] = [
    name: "testSchedule",
    cron: "00 00 00 * * *",
    job: () => {
        console.log("Welcome!")
    },
];

Releases

No releases published

Packages

No packages published