0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-02-10 23:39:31 -05:00
verdaccio/test/functional/lib/simple_server.ts
Juan Picado 93468211d6
chore: update eslint dependencies (#2126)
* chore: update eslint

* chore: update rules and style

* chore: aling formatting

* chore: update ci rules

* chore: aling formatting

* chore: aling formatting
2021-03-14 08:42:46 +01:00

38 lines
874 B
TypeScript

import express from 'express';
import bodyParser from 'body-parser';
/**
* 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));
});
}
}