mirror of
https://github.com/pure-admin/pure-admin-backend.git
synced 2025-12-15 06:40:36 +08:00
feat: add expires in login
This commit is contained in:
56
src/app.ts
56
src/app.ts
@@ -1,31 +1,33 @@
|
||||
import * as express from "express"
|
||||
import * as bodyParser from "body-parser"
|
||||
import * as express from "express";
|
||||
import * as bodyParser from "body-parser";
|
||||
|
||||
class App {
|
||||
public app: express.Application
|
||||
constructor() {
|
||||
this.app = express()
|
||||
this.config()
|
||||
}
|
||||
private config(): void {
|
||||
// 支持json编码的主体
|
||||
this.app.use(bodyParser.json())
|
||||
// 支持编码的主体
|
||||
this.app.use(bodyParser.urlencoded({
|
||||
extended: true,
|
||||
}))
|
||||
// 设置静态访问目录(Swagger)
|
||||
this.app.use(express.static('public'))
|
||||
// 设置跨域访问
|
||||
this.app.all('*', (req, res, next) => {
|
||||
res.header('Access-Control-Allow-Origin', '*')
|
||||
res.header('Access-Control-Allow-Headers', 'content-type')
|
||||
res.header('Access-Control-Allow-Methods', 'PUT,POST,GET,DELETE,OPTIONS')
|
||||
res.header('X-Powered-By', ' 3.2.1')
|
||||
res.header('Content-Type', 'application/json;charset=utf-8')
|
||||
next()
|
||||
})
|
||||
}
|
||||
public app: express.Application;
|
||||
constructor() {
|
||||
this.app = express();
|
||||
this.config();
|
||||
}
|
||||
private config(): void {
|
||||
// 支持json编码的主体
|
||||
this.app.use(bodyParser.json());
|
||||
// 支持编码的主体
|
||||
this.app.use(
|
||||
bodyParser.urlencoded({
|
||||
extended: true,
|
||||
})
|
||||
);
|
||||
// 设置静态访问目录(Swagger)
|
||||
this.app.use(express.static("public"));
|
||||
// 设置跨域访问
|
||||
this.app.all("*", (req, res, next) => {
|
||||
res.header("Access-Control-Allow-Origin", "*");
|
||||
res.header("Access-Control-Allow-Headers", "content-type");
|
||||
res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
|
||||
res.header("X-Powered-By", " 3.2.1");
|
||||
res.header("Content-Type", "application/json;charset=utf-8");
|
||||
next();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default new App().app
|
||||
export default new App().app;
|
||||
|
||||
Reference in New Issue
Block a user