express-zoa-server
Version:
Library to convert swagger file definition to basic express router ?
44 lines • 2.3 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const lib_1 = require("../lib");
const z_openapi_1 = require("z-openapi");
function basic() {
return __awaiter(this, void 0, void 0, function* () {
function main() {
return __awaiter(this, void 0, void 0, function* () {
const zoa = new z_openapi_1.Zopenapi()
.info(info => info
.title('Starter')
.version('1.0.0')
.description('Starter')).servers({ url: `http://localhost:${3000}/api/v1` });
const zoaConfig = {
api: '/api/v1',
apikey: 'mykey',
secret: 'mysecret',
dirname: __dirname,
mongoUrl: 'mongodb://localhost:27017/express-starter',
};
const server = yield lib_1.zoaServer(zoa, zoaConfig);
const { app } = yield server.start();
app.listen(3000, () => {
console.log(`Rest API at: http://localhost:${3000}/api/v1`);
console.log(`Graphql API at: http://localhost:${3000}/graphql`);
console.log(`Swagger for Rest API at: http://localhost:${3000}/api/v1/docs`);
console.log(`Playground for Graphql API at: http://localhost:${3000}/playground`);
});
});
}
return main().catch(error => console.error(error));
});
}
exports.basic = basic;
//# sourceMappingURL=basic.js.map