0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-01-20 22:52:46 -05:00
verdaccio/test/functional/lib/simple_server.ts
Juan Picado f9f269ee04
feat: refactor render middleware and audit plugin (#3602)
* chore: replace web middleware

* clean up

* migrate user agent

* migrate rate limit

* clean up

* replace audit plugin

* feat: refactor render middleware and audit plugin

* update deps

* update deps

* update packages

* update deps

* chore: update deps

* update deps

* update config dep

* chore: update deps

* update deps
2023-02-14 22:20:11 +01:00

37 lines
831 B
TypeScript

import express from 'express';
/**
* Simple Server
*
* A empty express server with the objective to emumate any external API.
*
* eg: test/functional/tags/tags.ts
*
* express.get('/testexp_tags', function(req, res) {
let f = readTags().toString().replace(/__NAME__/g, 'testexp_tags');
res.send(JSON.parse(f));
});
*
* or at test/functional/package/gzip.ts
*/
export default class ExpressServer {
private app: any;
private server: any;
public constructor() {
this.app = express();
}
public start(port: number): Promise<ExpressServer> {
return new Promise((resolve) => {
this.app.use(express.json());
this.app.use(
express.urlencoded({
extended: true,
})
);
this.server = this.app.listen(port, () => resolve(this));
});
}
}