@asapjs/core 0.0.7 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/application.d.ts +1 -1
- package/dist/application.d.ts.map +1 -1
- package/dist/application.js +5 -5
- package/dist/application.js.map +1 -1
- package/dist/config/index.d.ts +36 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js.map +1 -1
- package/package.json +1 -1
- package/.prettierrc +0 -8
- package/dist/middleware/errorHandler.d.ts +0 -9
- package/dist/middleware/errorHandler.d.ts.map +0 -1
- package/dist/middleware/errorHandler.js +0 -17
- package/dist/middleware/errorHandler.js.map +0 -1
- package/dist/sequelize/index.d.ts +0 -8
- package/dist/sequelize/index.d.ts.map +0 -1
- package/dist/sequelize/index.js +0 -67
- package/dist/sequelize/index.js.map +0 -1
- package/src/application.ts +0 -36
- package/src/config/index.ts +0 -7
- package/src/index.ts +0 -3
- package/src/util/logger.ts +0 -25
package/dist/application.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../src/application.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,OAAO,OAAO,WAAW;IAC9B,OAAO,CAAC,MAAM,CAAM;IAEpB,OAAO,CAAC,GAAG,CAAsB;gBAErB,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG;
|
|
1
|
+
{"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../src/application.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,OAAO,OAAO,WAAW;IAC9B,OAAO,CAAC,MAAM,CAAM;IAEpB,OAAO,CAAC,GAAG,CAAsB;gBAErB,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG;IAK/C,OAAO,CAAC,WAAW,CASjB;IAEK,GAAG,sBAKR;CACH"}
|
package/dist/application.js
CHANGED
|
@@ -27,14 +27,14 @@ class Application {
|
|
|
27
27
|
yield (0, sequelize_1.initSequelizeModule)(dirname);
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
-
this.run = (
|
|
30
|
+
this.run = () => __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
yield this.initMoudles(this.config.dirname);
|
|
31
32
|
this.app
|
|
32
|
-
.listen(port, () => logger_1.default.info(`@express :: Server is listening at ${port}`))
|
|
33
|
+
.listen(this.config.port, () => logger_1.default.info(`@express :: Server is listening at ${this.config.port}`))
|
|
33
34
|
.on('error', (error) => logger_1.default.error(error));
|
|
34
|
-
};
|
|
35
|
+
});
|
|
35
36
|
(0, config_1.setConfig)(projectConfig);
|
|
36
|
-
this.config = projectConfig;
|
|
37
|
-
this.initMoudles(dirname);
|
|
37
|
+
this.config = Object.assign({ dirname }, projectConfig);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
exports.default = Application;
|
package/dist/application.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application.js","sourceRoot":"","sources":["../src/application.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,iDAAwD;AACxD,2CAA8C;AAI9C,2DAAmC;AACnC,qCAAqC;AAErC,MAAqB,WAAW;IAK9B,YAAY,OAAe,EAAE,aAAkB;
|
|
1
|
+
{"version":3,"file":"application.js","sourceRoot":"","sources":["../src/application.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,iDAAwD;AACxD,2CAA8C;AAI9C,2DAAmC;AACnC,qCAAqC;AAErC,MAAqB,WAAW;IAK9B,YAAY,OAAe,EAAE,aAAkB;QAKvC,gBAAW,GAAG,CAAO,OAAe,EAAE,EAAE;YAC9C,6BAA6B;YAC7B,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,qBAAY,CAAC,OAAO,CAAC,CAAC;YAC1C,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;YAEf,gCAAgC;YAChC,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,mBAAmB,CAAC,EAAE;gBACxD,MAAM,IAAA,+BAAmB,EAAC,OAAO,CAAC,CAAC;aACpC;QACH,CAAC,CAAA,CAAC;QAEK,QAAG,GAAG,GAAS,EAAE;YACtB,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAC5C,IAAI,CAAC,GAAG;iBACL,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,gBAAM,CAAC,IAAI,CAAC,sCAAsC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;iBACrG,EAAE,CAAC,OAAO,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,gBAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;QACzD,CAAC,CAAA,CAAC;QApBA,IAAA,kBAAS,EAAC,aAAa,CAAC,CAAC;QACzB,IAAI,CAAC,MAAM,mBAAK,OAAO,IAAK,aAAa,CAAE,CAAC;IAC9C,CAAC;CAmBF;AA3BD,8BA2BC"}
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,4 +1,39 @@
|
|
|
1
|
+
interface IConfig {
|
|
2
|
+
dirname: string;
|
|
3
|
+
debug: boolean;
|
|
4
|
+
name: string;
|
|
5
|
+
extensions: string[];
|
|
6
|
+
port: number;
|
|
7
|
+
basePath: string;
|
|
8
|
+
swagger: {
|
|
9
|
+
name: string;
|
|
10
|
+
version: string;
|
|
11
|
+
description: string;
|
|
12
|
+
scheme: 'http' | 'https';
|
|
13
|
+
host: string;
|
|
14
|
+
};
|
|
15
|
+
auth: {
|
|
16
|
+
jwt_secret: string;
|
|
17
|
+
};
|
|
18
|
+
db: {
|
|
19
|
+
database: string;
|
|
20
|
+
username: string;
|
|
21
|
+
password?: string;
|
|
22
|
+
host: string;
|
|
23
|
+
port: number;
|
|
24
|
+
dialect: string;
|
|
25
|
+
logging?: (query: string, time: number) => void;
|
|
26
|
+
timezone?: string;
|
|
27
|
+
pool?: {
|
|
28
|
+
max: number;
|
|
29
|
+
idle: number;
|
|
30
|
+
acquire: number;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
extra: any;
|
|
34
|
+
}
|
|
1
35
|
export declare let config: null;
|
|
2
|
-
export declare const getConfig: () => null;
|
|
36
|
+
export declare const getConfig: () => IConfig | null;
|
|
3
37
|
export declare const setConfig: (v: any) => void;
|
|
38
|
+
export {};
|
|
4
39
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,eAAO,IAAI,MAAM,MAAO,CAAC;AAEzB,eAAO,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,UAAU,OAAO;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,MAAM,CAAC;QACpB,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;QACzB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,IAAI,EAAE;QACJ,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,EAAE,EAAE;QACF,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;QAChD,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,IAAI,CAAC,EAAE;YACL,GAAG,EAAE,MAAM,CAAC;YACZ,IAAI,EAAE,MAAM,CAAC;YACb,OAAO,EAAE,MAAM,CAAC;SACjB,CAAC;KACH,CAAC;IACF,KAAK,EAAE,GAAG,CAAC;CACZ;AAED,eAAO,IAAI,MAAM,MAAO,CAAC;AAEzB,eAAO,MAAM,SAAS,EAAE,MAAM,OAAO,GAAG,IAAmB,CAAC;AAE5D,eAAO,MAAM,SAAS,MAAO,GAAG,SAE/B,CAAC"}
|
package/dist/config/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":";;;AAmCW,QAAA,MAAM,GAAG,IAAI,CAAC;AAElB,MAAM,SAAS,GAAyB,GAAG,EAAE,CAAC,cAAM,CAAC;AAA/C,QAAA,SAAS,aAAsC;AAErD,MAAM,SAAS,GAAG,CAAC,CAAM,EAAE,EAAE;IAClC,cAAM,GAAG,CAAC,CAAC;AACb,CAAC,CAAC;AAFW,QAAA,SAAS,aAEpB"}
|
package/package.json
CHANGED
package/.prettierrc
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { NextFunction, Request, Response } from 'express';
|
|
2
|
-
export declare class HttpException extends Error {
|
|
3
|
-
status: number;
|
|
4
|
-
message: string;
|
|
5
|
-
constructor(status?: number, message?: string);
|
|
6
|
-
}
|
|
7
|
-
declare const errorHandler: (error: HttpException, req: Request, res: Response, next: NextFunction) => void;
|
|
8
|
-
export default errorHandler;
|
|
9
|
-
//# sourceMappingURL=errorHandler.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errorHandler.d.ts","sourceRoot":"","sources":["../../src/middleware/errorHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE1D,qBAAa,aAAc,SAAQ,KAAK;IAC/B,MAAM,EAAE,MAAM,CAAC;IAEf,OAAO,EAAE,MAAM,CAAC;gBAEX,MAAM,GAAE,MAAY,EAAE,OAAO,GAAE,MAAgC;CAK5E;AAED,QAAA,MAAM,YAAY,UAAW,aAAa,OAAO,OAAO,OAAO,QAAQ,QAAQ,YAAY,SAG1F,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HttpException = void 0;
|
|
4
|
-
class HttpException extends Error {
|
|
5
|
-
constructor(status = 500, message = '알 수 없는 서버 오류가 발생했습니다.') {
|
|
6
|
-
super(message);
|
|
7
|
-
this.status = status;
|
|
8
|
-
this.message = message;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.HttpException = HttpException;
|
|
12
|
-
const errorHandler = (error, req, res, next) => {
|
|
13
|
-
const { status = 500, message } = error;
|
|
14
|
-
res.status(status).json({ status, message });
|
|
15
|
-
};
|
|
16
|
-
exports.default = errorHandler;
|
|
17
|
-
//# sourceMappingURL=errorHandler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errorHandler.js","sourceRoot":"","sources":["../../src/middleware/errorHandler.ts"],"names":[],"mappings":";;;AAEA,MAAa,aAAc,SAAQ,KAAK;IAKtC,YAAY,SAAiB,GAAG,EAAE,UAAkB,uBAAuB;QACzE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AAVD,sCAUC;AAED,MAAM,YAAY,GAAG,CAAC,KAAoB,EAAE,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAE,EAAE;IAC7F,MAAM,EAAE,MAAM,GAAG,GAAG,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IACxC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;AAC/C,CAAC,CAAC;AAEF,kBAAe,YAAY,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Sequelize, SequelizeOptions } from 'sequelize-typescript';
|
|
2
|
-
import 'reflect-metadata';
|
|
3
|
-
export declare const dbInit: (config: SequelizeOptions) => Promise<Sequelize>;
|
|
4
|
-
export declare const loadPath: (path: string, subPath: string) => Promise<void>;
|
|
5
|
-
export declare const addModelsToSequelize: () => Promise<void>;
|
|
6
|
-
export declare const modelsSync: () => Promise<boolean>;
|
|
7
|
-
export declare const getSequelize: () => Sequelize;
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sequelize/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,SAAS,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAKrF,OAAO,kBAAkB,CAAC;AAQ1B,eAAO,MAAM,MAAM,WAAkB,gBAAgB,uBAepD,CAAC;AAEF,eAAO,MAAM,QAAQ,SAAgB,MAAM,WAAW,MAAM,kBAY3D,CAAC;AAEF,eAAO,MAAM,oBAAoB,qBAGhC,CAAC;AAEF,eAAO,MAAM,UAAU,wBAItB,CAAC;AAEF,eAAO,MAAM,YAAY,iBAAmB,CAAC"}
|
package/dist/sequelize/index.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.getSequelize = exports.modelsSync = exports.addModelsToSequelize = exports.loadPath = exports.dbInit = void 0;
|
|
16
|
-
const sequelize_typescript_1 = require("sequelize-typescript");
|
|
17
|
-
const fs_1 = __importDefault(require("fs"));
|
|
18
|
-
const logger_1 = __importDefault(require("../util/logger"));
|
|
19
|
-
require("reflect-metadata");
|
|
20
|
-
let container = null;
|
|
21
|
-
const models = [];
|
|
22
|
-
const dtos = [];
|
|
23
|
-
const dbInit = (config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
-
const sequelize = new sequelize_typescript_1.Sequelize(config);
|
|
25
|
-
container = sequelize;
|
|
26
|
-
sequelize
|
|
27
|
-
.authenticate()
|
|
28
|
-
.then(() => {
|
|
29
|
-
logger_1.default.info('@sequelize :: Database connected.');
|
|
30
|
-
})
|
|
31
|
-
.catch((err) => {
|
|
32
|
-
logger_1.default.error('@sequelize :: Unable to connect to the database:\n', err);
|
|
33
|
-
});
|
|
34
|
-
logger_1.default.info('@sequelize :: database initalize.');
|
|
35
|
-
return sequelize;
|
|
36
|
-
});
|
|
37
|
-
exports.dbInit = dbInit;
|
|
38
|
-
const loadPath = (path, subPath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
-
const files = yield fs_1.default.readdirSync(path + subPath, { withFileTypes: true });
|
|
40
|
-
const extension = process.env.NODE_ENV === 'production' ? 'js' : 'ts';
|
|
41
|
-
for (const file of files) {
|
|
42
|
-
if (file.isDirectory()) {
|
|
43
|
-
yield (0, exports.loadPath)(path, `${subPath}/${file.name}`);
|
|
44
|
-
}
|
|
45
|
-
else if (file.name.includes(`Table.${extension}`) && file.name.endsWith('map') === false) {
|
|
46
|
-
models.push(require(`${path}/${subPath}/${file.name}`).default);
|
|
47
|
-
}
|
|
48
|
-
else if (file.name.includes(`Dto.${extension}`) && file.name.endsWith('map') === false) {
|
|
49
|
-
dtos.push(require(`${path}/${subPath}/${file.name}`).default);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
exports.loadPath = loadPath;
|
|
54
|
-
const addModelsToSequelize = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
55
|
-
container.addModels(models);
|
|
56
|
-
logger_1.default.info('@sequelize :: add models to sequelize instance.');
|
|
57
|
-
});
|
|
58
|
-
exports.addModelsToSequelize = addModelsToSequelize;
|
|
59
|
-
const modelsSync = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
|
-
yield container.sync({ alter: { drop: false } });
|
|
61
|
-
logger_1.default.info('@sequelize :: models sync finished');
|
|
62
|
-
return true;
|
|
63
|
-
});
|
|
64
|
-
exports.modelsSync = modelsSync;
|
|
65
|
-
const getSequelize = () => container;
|
|
66
|
-
exports.getSequelize = getSequelize;
|
|
67
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sequelize/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+DAAqF;AACrF,4CAAoB;AAEpB,4DAAoC;AAEpC,4BAA0B;AAE1B,IAAI,SAAS,GAAqB,IAAI,CAAC;AAEvC,MAAM,MAAM,GAAiC,EAAE,CAAC;AAEhD,MAAM,IAAI,GAAU,EAAE,CAAC;AAEhB,MAAM,MAAM,GAAG,CAAO,MAAwB,EAAE,EAAE;IACvD,MAAM,SAAS,GAAG,IAAI,gCAAS,CAAC,MAAM,CAAC,CAAC;IACxC,SAAS,GAAG,SAAS,CAAC;IACtB,SAAS;SACN,YAAY,EAAE;SACd,IAAI,CAAC,GAAG,EAAE;QACT,gBAAM,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;IACnD,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QACb,gBAAM,CAAC,KAAK,CAAC,oDAAoD,EAAE,GAAG,CAAC,CAAC;IAC1E,CAAC,CAAC,CAAC;IAEL,gBAAM,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;IAEjD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAA,CAAC;AAfW,QAAA,MAAM,UAejB;AAEK,MAAM,QAAQ,GAAG,CAAO,IAAY,EAAE,OAAe,EAAE,EAAE;IAC9D,MAAM,KAAK,GAAG,MAAM,YAAE,CAAC,WAAW,CAAC,IAAI,GAAG,OAAO,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5E,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IACtE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE;YACtB,MAAM,IAAA,gBAAQ,EAAC,IAAI,EAAE,GAAG,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;SACjD;aAAM,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,SAAS,EAAE,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,KAAK,EAAE;YAC1F,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,IAAI,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;SACjE;aAAM,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,SAAS,EAAE,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,KAAK,EAAE;YACxF,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,IAAI,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;SAC/D;KACF;AACH,CAAC,CAAA,CAAC;AAZW,QAAA,QAAQ,YAYnB;AAEK,MAAM,oBAAoB,GAAG,GAAS,EAAE;IAC7C,SAAU,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC7B,gBAAM,CAAC,IAAI,CAAC,iDAAiD,CAAC,CAAC;AACjE,CAAC,CAAA,CAAC;AAHW,QAAA,oBAAoB,wBAG/B;AAEK,MAAM,UAAU,GAAG,GAAS,EAAE;IACnC,MAAM,SAAU,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;IAClD,gBAAM,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC;IAClD,OAAO,IAAI,CAAC;AACd,CAAC,CAAA,CAAC;AAJW,QAAA,UAAU,cAIrB;AAEK,MAAM,YAAY,GAAG,GAAG,EAAE,CAAC,SAAU,CAAC;AAAhC,QAAA,YAAY,gBAAoB"}
|
package/src/application.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { initSequelizeModule } from '@asapjs/sequelize';
|
|
2
|
-
import { RouterModule } from '@asapjs/router';
|
|
3
|
-
|
|
4
|
-
import express from 'express';
|
|
5
|
-
|
|
6
|
-
import logger from './util/logger';
|
|
7
|
-
import { setConfig } from './config';
|
|
8
|
-
|
|
9
|
-
export default class Application {
|
|
10
|
-
private config: any;
|
|
11
|
-
|
|
12
|
-
private app: express.Application;
|
|
13
|
-
|
|
14
|
-
constructor(dirname: string, projectConfig: any) {
|
|
15
|
-
setConfig(projectConfig);
|
|
16
|
-
this.config = projectConfig;
|
|
17
|
-
this.initMoudles(dirname);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
private initMoudles = async (dirname: string) => {
|
|
21
|
-
// init @asapjs/router module
|
|
22
|
-
const { app } = new RouterModule(dirname);
|
|
23
|
-
this.app = app;
|
|
24
|
-
|
|
25
|
-
// init @asapjs/sequelize module
|
|
26
|
-
if (this.config.extensions.includes('@asapjs/sequelize')) {
|
|
27
|
-
await initSequelizeModule(dirname);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
public run = (port: number) => {
|
|
32
|
-
this.app
|
|
33
|
-
.listen(port, () => logger.info(`@express :: Server is listening at ${port}`))
|
|
34
|
-
.on('error', (error: string) => logger.error(error));
|
|
35
|
-
};
|
|
36
|
-
}
|
package/src/config/index.ts
DELETED
package/src/index.ts
DELETED
package/src/util/logger.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { createLogger, transports, format } from 'winston';
|
|
2
|
-
|
|
3
|
-
interface TransformableInfo {
|
|
4
|
-
level: string;
|
|
5
|
-
message: string;
|
|
6
|
-
[key: string]: any;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const logger = createLogger({
|
|
10
|
-
transports: [
|
|
11
|
-
new transports.Console({
|
|
12
|
-
level: 'debug',
|
|
13
|
-
format: format.combine(
|
|
14
|
-
format.label({ label: '[shop]' }),
|
|
15
|
-
format.timestamp({
|
|
16
|
-
format: 'YYYY-MM-DD HH:mm:ss',
|
|
17
|
-
}),
|
|
18
|
-
format.colorize(),
|
|
19
|
-
format.printf((info: TransformableInfo) => `${info.timestamp} - ${info.level}: ${info.label} ${info.message}`),
|
|
20
|
-
),
|
|
21
|
-
}),
|
|
22
|
-
],
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
export default logger;
|