0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-16 21:56:25 -05:00
verdaccio/test/functional/lib/simple_server.ts
Juan Picado 558fcafc71
build: format code prettier, enable ci (#2886)
* fix: format code prettier, enable ci

* chore: add trivago import prettier pluggin
2022-01-09 20:51:50 +01:00

38 lines
875 B
TypeScript

import bodyParser from 'body-parser';
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(bodyParser.json());
this.app.use(
bodyParser.urlencoded({
extended: true,
})
);
this.server = this.app.listen(port, () => resolve(this));
});
}
}