1.4.3 • Published 4 months ago
common-api-ts v1.4.3
common-api-ts
Simple backend framework with JWT and MySQL support.
Installation into an existing project
To install common-api-ts
as a dependency of your Node.js project:
npm install common-api-ts
common-api-ts
is made with TypeScript, so you don't need to download DefinitelyTyped package.
How to use
import {
App,
Config,
ModelBase,
Schedule,
initializeConfig,
initializeScheduler,
logger,
} from "common-api-ts";
import path from "path";
initializeConfig(config);
initializeScheduler(schedules);
runExpressApp();
function runExpressApp() {
const app = new App(
path.join(__dirname, "router"),
[],
routerMiddleware,
[]
);
app.run(
config.port,
() => {
console.info(`Server started with port: ${config.port}`);
},
(error) => {
logger.error(error);
}
);
}
const config: Config = {
jwtSecret: "secret",
db: {
host: "127.0.0.1",
port: 3306,
user: "root",
password: "password",
database: "db",
},
};
const schedules: Schedule[] = [
name: "testSchedule",
cron: "00 00 00 * * *",
job: () => {
console.log("Welcome!")
},
];
1.4.3
4 months ago
1.4.2
4 months ago
1.4.1
4 months ago
1.4.0
4 months ago
1.3.4
4 months ago
1.3.3
11 months ago
1.3.2
11 months ago
1.3.1
12 months ago
1.3.0
12 months ago
1.1.1
1 year ago
1.1.0
1 year ago
1.1.3
1 year ago
1.1.2
1 year ago
1.0.8
1 year ago
1.0.6
1 year ago
1.0.5
1 year ago
1.0.4
1 year ago
1.0.3
1 year ago
1.0.2
1 year ago
1.0.1
1 year ago
1.0.0
1 year ago