Best JavaScript code snippet using wpt
get-api-complete-operation.spec.ts
Source:get-api-complete-operation.spec.ts
1import { deepStrictEqual, strictEqual } from 'assert';2import {3 ApiCallback, ApiDeprecated, ApiExternalDoc, ApiOperation, ApiOperationDescription, ApiOperationId,4 ApiOperationSummary, ApiParameter, ApiRequestBody, ApiResponse, ApiSecurityRequirement, ApiServer, ApiUseTag5} from '../decorators';6import {7 IApiCallback, IApiExternalDocumentation, IApiOperation, IApiParameter, IApiRequestBody,8 IApiResponse, IApiSecurityRequirement, IApiServer9} from '../interfaces';10import { getApiCompleteOperation } from './get-api-complete-operation';11describe('getApiCompleteOperation', () => {12 describe('should return the tags of', () => {13 it('a class.', () => {14 class Controller {}15 const operation = getApiCompleteOperation(Controller, new Controller());16 strictEqual(operation.hasOwnProperty('tags'), false);17 @ApiUseTag('tag1')18 class Controller2 {}19 const operation2 = getApiCompleteOperation(Controller2, new Controller2());20 deepStrictEqual(operation2.tags, [ 'tag1' ]);21 });22 it('a class (dynamic tag).', () => {23 class Controller {}24 const operation = getApiCompleteOperation(Controller, new Controller());25 strictEqual(operation.hasOwnProperty('tags'), false);26 @ApiUseTag((controller: Controller2) => controller.tag)27 class Controller2 {28 tag: string = 'tag1';29 }30 const operation2 = getApiCompleteOperation(Controller2, new Controller2());31 deepStrictEqual(operation2.tags, [ 'tag1' ]);32 });33 it('a class method.', () => {34 class Controller {35 foo() {}36 }37 const operation = getApiCompleteOperation(Controller, new Controller(), 'foo');38 strictEqual(operation.hasOwnProperty('tags'), false);39 class Controller2 {40 @ApiUseTag('tag1')41 foo() {}42 }43 const operation2 = getApiCompleteOperation(Controller2, new Controller2(), 'foo');44 deepStrictEqual(operation2.tags, [ 'tag1' ]);45 });46 });47 describe('should return the summary of', () => {48 it('a class.', () => {49 class Controller {}50 const operation = getApiCompleteOperation(Controller, new Controller());51 strictEqual(operation.hasOwnProperty('summary'), false);52 @ApiOperationSummary('')53 class Controller2 {}54 const operation2 = getApiCompleteOperation(Controller2, new Controller2());55 strictEqual(operation2.summary, '');56 });57 it('a class (dynamic summary).', () => {58 class Controller {}59 const operation = getApiCompleteOperation(Controller, new Controller());60 strictEqual(operation.hasOwnProperty('summary'), false);61 @ApiOperationSummary((controller: Controller2) => controller.summary)62 class Controller2 {63 summary = '';64 }65 const operation2 = getApiCompleteOperation(Controller2, new Controller2());66 strictEqual(operation2.summary, '');67 });68 it('a class method.', () => {69 class Controller {70 foo() {}71 }72 const operation = getApiCompleteOperation(Controller, new Controller(), 'foo');73 strictEqual(operation.hasOwnProperty('summary'), false);74 class Controller2 {75 @ApiOperationSummary('')76 foo() {}77 }78 const operation2 = getApiCompleteOperation(Controller2, new Controller2(), 'foo');79 strictEqual(operation2.summary, '');80 });81 });82 describe('should return the operationId of', () => {83 it('a class.', () => {84 class Controller {}85 const operation = getApiCompleteOperation(Controller, new Controller());86 strictEqual(operation.hasOwnProperty('operationId'), false);87 @ApiOperationId('')88 class Controller2 {}89 const operation2 = getApiCompleteOperation(Controller2, new Controller2());90 strictEqual(operation2.operationId, '');91 });92 it('a class (dynamic operationId).', () => {93 class Controller {}94 const operation = getApiCompleteOperation(Controller, new Controller());95 strictEqual(operation.hasOwnProperty('operationId'), false);96 @ApiOperationId((controller: Controller2) => controller.operationId)97 class Controller2 {98 operationId = '';99 }100 const operation2 = getApiCompleteOperation(Controller2, new Controller2());101 strictEqual(operation2.operationId, '');102 });103 it('a class method.', () => {104 class Controller {105 foo() {}106 }107 const operation = getApiCompleteOperation(Controller, new Controller(), 'foo');108 strictEqual(operation.hasOwnProperty('operationId'), false);109 class Controller2 {110 @ApiOperationId('')111 foo() {}112 }113 const operation2 = getApiCompleteOperation(Controller2, new Controller2(), 'foo');114 strictEqual(operation2.operationId, '');115 });116 });117 describe('should return the description of', () => {118 it('a class.', () => {119 class Controller {}120 const operation = getApiCompleteOperation(Controller, new Controller());121 strictEqual(operation.hasOwnProperty('description'), false);122 @ApiOperationDescription('')123 class Controller2 {}124 const operation2 = getApiCompleteOperation(Controller2, new Controller2());125 strictEqual(operation2.description, '');126 });127 it('a class (dynamic description).', () => {128 class Controller {}129 const operation = getApiCompleteOperation(Controller, new Controller());130 strictEqual(operation.hasOwnProperty('description'), false);131 @ApiOperationDescription((controller: Controller2) => controller.description)132 class Controller2 {133 description = '';134 }135 const operation2 = getApiCompleteOperation(Controller2, new Controller2());136 strictEqual(operation2.description, '');137 });138 it('a class method.', () => {139 class Controller {140 foo() {}141 }142 const operation = getApiCompleteOperation(Controller, new Controller(), 'foo');143 strictEqual(operation.hasOwnProperty('description'), false);144 class Controller2 {145 @ApiOperationDescription('')146 foo() {}147 }148 const operation2 = getApiCompleteOperation(Controller2, new Controller2(), 'foo');149 strictEqual(operation2.description, '');150 });151 });152 describe('should return the external documentation of', () => {153 it('a class.', () => {154 class Controller {}155 const operation = getApiCompleteOperation(Controller, new Controller());156 strictEqual(operation.hasOwnProperty('externalDocs'), false);157 const doc: IApiExternalDocumentation = {158 url: 'http://example.com/docs'159 };160 @ApiExternalDoc(doc)161 class Controller2 {}162 const operation2 = getApiCompleteOperation(Controller2, new Controller2());163 strictEqual(operation2.externalDocs, doc);164 });165 it('a class (dynamic external documentation).', () => {166 class Controller {}167 const operation = getApiCompleteOperation(Controller, new Controller());168 strictEqual(operation.hasOwnProperty('externalDocs'), false);169 const doc: IApiExternalDocumentation = {170 url: 'http://example.com/docs'171 };172 @ApiExternalDoc((controller: Controller2) => controller.doc)173 class Controller2 {174 doc = doc;175 }176 const operation2 = getApiCompleteOperation(Controller2, new Controller2());177 strictEqual(operation2.externalDocs, doc);178 });179 it('a class method.', () => {180 class Controller {181 foo() {}182 }183 const operation = getApiCompleteOperation(Controller, new Controller(), 'foo');184 strictEqual(operation.hasOwnProperty('externalDocs'), false);185 const doc: IApiExternalDocumentation = {186 url: 'http://example.com/docs'187 };188 class Controller2 {189 @ApiExternalDoc(doc)190 foo() {}191 }192 const operation2 = getApiCompleteOperation(Controller2, new Controller2(), 'foo');193 strictEqual(operation2.externalDocs, doc);194 });195 });196 describe('should return the operationId of', () => {197 it('a class method.', () => {198 class Controller {199 foo() {}200 }201 const operation = getApiCompleteOperation(Controller, new Controller(), 'foo');202 strictEqual(operation.hasOwnProperty('operationId'), false);203 class Controller3 {204 @ApiOperation({205 responses: {},206 })207 foo() {}208 }209 const operation3 = getApiCompleteOperation(Controller3, new Controller3(), 'foo');210 strictEqual(operation3.hasOwnProperty('operationId'), false);211 class Controller2 {212 @ApiOperation({213 operationId: 'foo1',214 responses: {},215 })216 foo() {}217 }218 const operation2 = getApiCompleteOperation(Controller2, new Controller2(), 'foo');219 strictEqual(operation2.operationId, 'foo1');220 });221 });222 describe('should return the parameters of', () => {223 it('a class.', () => {224 class Controller {}225 const operation = getApiCompleteOperation(Controller, new Controller());226 strictEqual(operation.hasOwnProperty('parameters'), false);227 const param: IApiParameter = {228 in: 'cookie',229 name: 'parameter1'230 };231 @ApiParameter(param)232 class Controller2 {}233 const operation2 = getApiCompleteOperation(Controller2, new Controller2());234 deepStrictEqual(operation2.parameters, [ param ]);235 });236 it('a class (dynamic parameters).', () => {237 class Controller {}238 const operation = getApiCompleteOperation(Controller, new Controller());239 strictEqual(operation.hasOwnProperty('parameters'), false);240 const param: IApiParameter = {241 in: 'cookie',242 name: 'parameter1'243 };244 @ApiParameter((controller: Controller2) => controller.param)245 class Controller2 {246 param = param;247 }248 const operation2 = getApiCompleteOperation(Controller2, new Controller2());249 deepStrictEqual(operation2.parameters, [ param ]);250 });251 it('a class method.', () => {252 class Controller {253 foo() {}254 }255 const operation = getApiCompleteOperation(Controller, new Controller(), 'foo');256 strictEqual(operation.hasOwnProperty('parameters'), false);257 const param: IApiParameter = {258 in: 'cookie',259 name: 'parameter1'260 };261 class Controller2 {262 @ApiParameter(param)263 foo() {}264 }265 const operation2 = getApiCompleteOperation(Controller2, new Controller2(), 'foo');266 deepStrictEqual(operation2.parameters, [ param ]);267 });268 });269 describe('should return the request body of', () => {270 it('a class.', () => {271 class Controller {}272 const operation = getApiCompleteOperation(Controller, new Controller());273 strictEqual(operation.hasOwnProperty('requestBody'), false);274 const requestBody: IApiRequestBody = {275 content: {}276 };277 @ApiRequestBody(requestBody)278 class Controller2 {}279 const operation2 = getApiCompleteOperation(Controller2, new Controller2());280 strictEqual(operation2.requestBody, requestBody);281 });282 it('a class (dynamic request body).', () => {283 class Controller {}284 const operation = getApiCompleteOperation(Controller, new Controller());285 strictEqual(operation.hasOwnProperty('requestBody'), false);286 @ApiRequestBody((controller: Controller2) => controller.requestBody)287 class Controller2 {288 requestBody: IApiRequestBody = {289 content: {}290 };291 }292 const controller2 = new Controller2();293 const operation2 = getApiCompleteOperation(Controller2, controller2);294 strictEqual(operation2.requestBody, controller2.requestBody);295 });296 it('a class method.', () => {297 class Controller {298 foo() {}299 }300 const operation = getApiCompleteOperation(Controller, new Controller(), 'foo');301 strictEqual(operation.hasOwnProperty('requestBody'), false);302 const requestBody: IApiRequestBody = {303 content: {}304 };305 class Controller2 {306 @ApiRequestBody(requestBody)307 foo() {}308 }309 const operation2 = getApiCompleteOperation(Controller2, new Controller2(), 'foo');310 strictEqual(operation2.requestBody, requestBody);311 });312 });313 describe('should return the responses of', () => {314 it('a class.', () => {315 class Controller {}316 const operation = getApiCompleteOperation(Controller, new Controller());317 deepStrictEqual(operation.responses, {});318 const response: IApiResponse = {319 description: 'response1'320 };321 @ApiResponse(200, response)322 class Controller2 {}323 const operation2 = getApiCompleteOperation(Controller2, new Controller2());324 deepStrictEqual(operation2.responses, { 200: response });325 });326 it('a class (dynamic responses).', () => {327 class Controller {}328 const operation = getApiCompleteOperation(Controller, new Controller());329 deepStrictEqual(operation.responses, {});330 const response: IApiResponse = {331 description: 'response1'332 };333 const response2: IApiResponse = {334 description: 'response2'335 };336 @ApiResponse(200, (controller: Controller2) => controller.response)337 @ApiResponse('default', (controller: Controller2) => controller.response2)338 class Controller2 {339 response = response;340 response2 = response2;341 }342 const operation2 = getApiCompleteOperation(Controller2, new Controller2());343 deepStrictEqual(operation2.responses, {344 200: response,345 default: response2,346 });347 });348 it('a class method.', () => {349 class Controller {350 foo() {}351 }352 const operation = getApiCompleteOperation(Controller, new Controller(), 'foo');353 deepStrictEqual(operation.responses, {});354 const response: IApiResponse = {355 description: 'response1'356 };357 class Controller2 {358 @ApiResponse(200, response)359 foo() {}360 }361 const operation2 = getApiCompleteOperation(Controller2, new Controller2(), 'foo');362 deepStrictEqual(operation2.responses, { 200: response });363 });364 });365 describe('should return the callbacks of', () => {366 it('a class.', () => {367 class Controller {}368 const operation = getApiCompleteOperation(Controller, new Controller());369 strictEqual(operation.hasOwnProperty('callbacks'), false);370 const callback: IApiCallback = {};371 @ApiCallback('callback1', callback)372 class Controller2 {}373 const operation2 = getApiCompleteOperation(Controller2, new Controller2());374 deepStrictEqual(operation2.callbacks, {375 callback1: callback376 });377 });378 it('a class (dynamic callbacks).', () => {379 class Controller {}380 const operation = getApiCompleteOperation(Controller, new Controller());381 strictEqual(operation.hasOwnProperty('callbacks'), false);382 const callback: IApiCallback = {};383 const callback2: IApiCallback = {};384 @ApiCallback('callback1', (controller: Controller2) => controller.callback1)385 @ApiCallback('callback2', (controller: Controller2) => controller.callback2)386 class Controller2 {387 callback1 = callback;388 callback2 = callback2;389 }390 const operation2 = getApiCompleteOperation(Controller2, new Controller2());391 deepStrictEqual(operation2.callbacks, {392 callback1: callback,393 callback2394 });395 });396 it('a class method.', () => {397 class Controller {398 foo() {}399 }400 const operation = getApiCompleteOperation(Controller, new Controller(), 'foo');401 strictEqual(operation.hasOwnProperty('callbacks'), false);402 const callback: IApiCallback = {};403 class Controller2 {404 @ApiCallback('callback1', callback)405 foo() {}406 }407 const operation2 = getApiCompleteOperation(Controller2, new Controller2(), 'foo');408 deepStrictEqual(operation2.callbacks, {409 callback1: callback410 });411 });412 });413 describe('should return the deprecated flag of', () => {414 it('a class.', () => {415 class Controller {}416 const operation = getApiCompleteOperation(Controller, new Controller());417 strictEqual(operation.hasOwnProperty('deprecated'), false);418 @ApiDeprecated(false)419 class Controller2 {}420 const operation2 = getApiCompleteOperation(Controller2, new Controller2());421 strictEqual(operation2.deprecated, false);422 });423 it('a class (dynamic deprecated flag).', () => {424 class Controller {}425 const operation = getApiCompleteOperation(Controller, new Controller());426 strictEqual(operation.hasOwnProperty('deprecated'), false);427 @ApiDeprecated((controller: Controller2) => controller.deprecated)428 class Controller2 {429 deprecated = false;430 }431 const operation2 = getApiCompleteOperation(Controller2, new Controller2());432 strictEqual(operation2.deprecated, false);433 });434 it('a class method.', () => {435 class Controller {436 foo() {}437 }438 const operation = getApiCompleteOperation(Controller, new Controller(), 'foo');439 strictEqual(operation.hasOwnProperty('deprecated'), false);440 class Controller2 {441 @ApiDeprecated(false)442 foo() {}443 }444 const operation2 = getApiCompleteOperation(Controller2, new Controller2(), 'foo');445 strictEqual(operation2.deprecated, false);446 });447 });448 describe('should return the security requirements of', () => {449 it('a class.', () => {450 class Controller {}451 const operation = getApiCompleteOperation(Controller, new Controller());452 strictEqual(operation.hasOwnProperty('security'), false);453 const securityRequirement: IApiSecurityRequirement = {};454 @ApiSecurityRequirement(securityRequirement)455 class Controller2 {}456 const operation2 = getApiCompleteOperation(Controller2, new Controller2());457 deepStrictEqual(operation2.security, [ securityRequirement ]);458 });459 it('a class (dynamic security requirements).', () => {460 class Controller {}461 const operation = getApiCompleteOperation(Controller, new Controller());462 strictEqual(operation.hasOwnProperty('security'), false);463 const securityRequirement: IApiSecurityRequirement = {};464 @ApiSecurityRequirement((controller: Controller2) => controller.securityRequirement)465 class Controller2 {466 securityRequirement = securityRequirement;467 }468 const operation2 = getApiCompleteOperation(Controller2, new Controller2());469 deepStrictEqual(operation2.security, [ securityRequirement ]);470 });471 it('a class method.', () => {472 class Controller {473 foo() {}474 }475 const operation = getApiCompleteOperation(Controller, new Controller(), 'foo');476 strictEqual(operation.hasOwnProperty('security'), false);477 const securityRequirement: IApiSecurityRequirement = {};478 class Controller2 {479 @ApiSecurityRequirement(securityRequirement)480 foo() {}481 }482 const operation2 = getApiCompleteOperation(Controller2, new Controller2(), 'foo');483 deepStrictEqual(operation2.security, [ securityRequirement ]);484 });485 });486 describe('should return the servers of', () => {487 it('a class.', () => {488 class Controller {}489 const operation = getApiCompleteOperation(Controller, new Controller());490 strictEqual(operation.hasOwnProperty('servers'), false);491 const server: IApiServer = {492 url: 'http://example.com'493 };494 @ApiServer(server)495 class Controller2 {}496 const operation2 = getApiCompleteOperation(Controller2, new Controller2());497 deepStrictEqual(operation2.servers, [ server ]);498 });499 it('a class (dynamic servers).', () => {500 class Controller {}501 const operation = getApiCompleteOperation(Controller, new Controller());502 strictEqual(operation.hasOwnProperty('servers'), false);503 const server: IApiServer = {504 url: 'http://example.com'505 };506 @ApiServer((controller: Controller2) => controller.server)507 class Controller2 {508 server = server;509 }510 const operation2 = getApiCompleteOperation(Controller2, new Controller2());511 deepStrictEqual(operation2.servers, [ server ]);512 });513 it('a class method.', () => {514 class Controller {515 foo() {}516 }517 const operation = getApiCompleteOperation(Controller, new Controller(), 'foo');518 strictEqual(operation.hasOwnProperty('servers'), false);519 const server: IApiServer = {520 url: 'http://example.com'521 };522 class Controller2 {523 @ApiServer(server)524 foo() {}525 }526 const operation2 = getApiCompleteOperation(Controller2, new Controller2(), 'foo');527 deepStrictEqual(operation2.servers, [ server ]);528 });529 });530 it('should return the values of @ApiOperation.', () => {531 const operation: IApiOperation = {532 callbacks: {533 a: { $ref: 'cb 1' }534 },535 deprecated: true,536 description: 'description 1',537 externalDocs: { url: 'http://example.com/docs' },538 operationId: 'foo 1',539 parameters: [540 { $ref: 'param 1' }541 ],542 requestBody: { $ref: 'body 1' },543 responses: {544 200: { $ref: '2' }545 },546 security: [ { a: ['security 1'] } ],547 servers: [ { url: 'http://example.com' }],548 summary: 'summary 1',549 tags: [ 'tag1' ],550 };551 class Controller {552 @ApiOperation(operation)553 foo() {}554 }555 const actual = getApiCompleteOperation(Controller, new Controller(), 'foo');556 deepStrictEqual(actual, operation);557 });558 it('should return the values of @ApiOperation (dynamic value).', () => {559 const operation: IApiOperation = {560 callbacks: {561 a: { $ref: 'cb 1' }562 },563 deprecated: true,564 description: 'description 1',565 externalDocs: { url: 'http://example.com/docs' },566 operationId: 'foo 1',567 parameters: [568 { $ref: 'param 1' }569 ],570 requestBody: { $ref: 'body 1' },571 responses: {572 200: { $ref: '2' }573 },574 security: [ { a: ['security 1'] } ],575 servers: [ { url: 'http://example.com' }],576 summary: 'summary 1',577 tags: [ 'tag1' ],578 };579 class Controller {580 operation = operation;581 @ApiOperation((controller: Controller) => controller.operation)582 foo() {}583 }584 const actual = getApiCompleteOperation(Controller, new Controller(), 'foo');585 deepStrictEqual(actual, operation);586 });...
routes.js
Source:routes.js
1"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _express = require('express');2var _expressbrute = require('express-brute'); var _expressbrute2 = _interopRequireDefault(_expressbrute);3var _expressbruteredis = require('express-brute-redis'); var _expressbruteredis2 = _interopRequireDefault(_expressbruteredis);4var _multer = require('multer'); var _multer2 = _interopRequireDefault(_multer);5// Configs6var _multer3 = require('./config/multer'); var _multer4 = _interopRequireDefault(_multer3);7// Middlewares8var _auth = require('./app/middlewares/auth'); var _auth2 = _interopRequireDefault(_auth);9// Validators10var _PKValidator = require('./app/validators/PKValidator'); var _PKValidator2 = _interopRequireDefault(_PKValidator);11var _SessionStoreValidator = require('./app/validators/SessionStoreValidator'); var _SessionStoreValidator2 = _interopRequireDefault(_SessionStoreValidator);12var _SessionStudentStoreValidator = require('./app/validators/SessionStudentStoreValidator'); var _SessionStudentStoreValidator2 = _interopRequireDefault(_SessionStudentStoreValidator);13var _StudentCreateValidator = require('./app/validators/StudentCreateValidator'); var _StudentCreateValidator2 = _interopRequireDefault(_StudentCreateValidator);14var _StudentUpdateValidator = require('./app/validators/StudentUpdateValidator'); var _StudentUpdateValidator2 = _interopRequireDefault(_StudentUpdateValidator);15var _PlanCreateValidator = require('./app/validators/PlanCreateValidator'); var _PlanCreateValidator2 = _interopRequireDefault(_PlanCreateValidator);16var _PlanUpdateValidator = require('./app/validators/PlanUpdateValidator'); var _PlanUpdateValidator2 = _interopRequireDefault(_PlanUpdateValidator);17var _EnrollmentCreateValidator = require('./app/validators/EnrollmentCreateValidator'); var _EnrollmentCreateValidator2 = _interopRequireDefault(_EnrollmentCreateValidator);18var _EnrollmentUpdateValidator = require('./app/validators/EnrollmentUpdateValidator'); var _EnrollmentUpdateValidator2 = _interopRequireDefault(_EnrollmentUpdateValidator);19var _HelpOrderCreateValidator = require('./app/validators/HelpOrderCreateValidator'); var _HelpOrderCreateValidator2 = _interopRequireDefault(_HelpOrderCreateValidator);20var _AnswerValidator = require('./app/validators/AnswerValidator'); var _AnswerValidator2 = _interopRequireDefault(_AnswerValidator);21// Controllers22var _SessionController = require('./app/controllers/SessionController'); var _SessionController2 = _interopRequireDefault(_SessionController);23var _SessionStudentController = require('./app/controllers/SessionStudentController'); var _SessionStudentController2 = _interopRequireDefault(_SessionStudentController);24var _FileController = require('./app/controllers/FileController'); var _FileController2 = _interopRequireDefault(_FileController);25var _StudentController = require('./app/controllers/StudentController'); var _StudentController2 = _interopRequireDefault(_StudentController);26var _CheckinController = require('./app/controllers/CheckinController'); var _CheckinController2 = _interopRequireDefault(_CheckinController);27var _PlanController = require('./app/controllers/PlanController'); var _PlanController2 = _interopRequireDefault(_PlanController);28var _EnrollmentController = require('./app/controllers/EnrollmentController'); var _EnrollmentController2 = _interopRequireDefault(_EnrollmentController);29var _HelpOrderController = require('./app/controllers/HelpOrderController'); var _HelpOrderController2 = _interopRequireDefault(_HelpOrderController);30var _NotificationController = require('./app/controllers/NotificationController'); var _NotificationController2 = _interopRequireDefault(_NotificationController);31var _AnswerController = require('./app/controllers/AnswerController'); var _AnswerController2 = _interopRequireDefault(_AnswerController);32// Variables33const routes = new (0, _express.Router)();34const upload = _multer2.default.call(void 0, _multer4.default);35routes.get('/', async (req, res) => {36 res.json({37 name: 'Api Bodytest',38 version: '1.2.0',39 mode: process.env.NODE_ENV,40 created_by: "Fernando Papito"41 });42});43// Apply Brute in production Mode44if (process.env.NODE_ENV === 'production') {45 const bruteStore = new (0, _expressbruteredis2.default)({46 host: process.env.HOST,47 port: process.env.PORT,48 });49 const bruteForce = new (0, _expressbrute2.default)(bruteStore);50 routes.post(51 '/sessions',52 bruteForce.prevent,53 _SessionStoreValidator2.default,54 _SessionController2.default.store55 );56} else {57 routes.post('/sessions', _SessionStoreValidator2.default, _SessionController2.default.store);58}59// Routes Students60routes.post(61 '/sessionsStudent',62 _SessionStudentStoreValidator2.default,63 _SessionStudentController2.default.store64);65routes.get('/students/:id/checkins', _PKValidator2.default, _CheckinController2.default.index);66routes.post('/students/:id/checkins', _PKValidator2.default, _CheckinController2.default.store);67routes.get('/students/:id/help-orders', _PKValidator2.default, _HelpOrderController2.default.index);68routes.post(69 '/students/:id/help-orders',70 _PKValidator2.default,71 _HelpOrderCreateValidator2.default,72 _HelpOrderController2.default.store73);74// Routes below is JWT AUTH required75routes.use(_auth2.default);76// Routes Students77routes.get('/students', _StudentController2.default.index);78routes.get('/students/:id', _PKValidator2.default, _StudentController2.default.show);79routes.post('/students', _StudentCreateValidator2.default, _StudentController2.default.store);80routes.put(81 '/students/:id',82 _PKValidator2.default,83 _StudentUpdateValidator2.default,84 _StudentController2.default.update85);86routes.delete('/students/:id', _PKValidator2.default, _StudentController2.default.destroy);87routes.post(88 '/students/:id/files',89 _PKValidator2.default,90 upload.single('file'),91 _FileController2.default.store92);93// Routes Help Order94routes.get('/help-orders', _AnswerController2.default.index);95routes.post(96 '/help-orders/:id/answer',97 _PKValidator2.default,98 _AnswerValidator2.default,99 _AnswerController2.default.store100);101// Notifications102routes.get('/notifications', _NotificationController2.default.index);103// Routes Plan104routes.get('/plans', _PlanController2.default.index);105routes.get('/plans/:id', _PKValidator2.default, _PlanController2.default.show);106routes.post('/plans', _PlanCreateValidator2.default, _PlanController2.default.store);107routes.put(108 '/plans/:id',109 _PKValidator2.default,110 _PlanUpdateValidator2.default,111 _PlanController2.default.update112);113routes.delete('/plans/:id', _PKValidator2.default, _PlanController2.default.delete);114// Routes Enrollment115routes.get('/enrollments', _EnrollmentController2.default.index);116routes.get('/enrollments/:id', _PKValidator2.default, _EnrollmentController2.default.show);117routes.post(118 '/enrollments',119 _EnrollmentCreateValidator2.default,120 _EnrollmentController2.default.store121);122routes.put(123 '/enrollments/:id',124 _PKValidator2.default,125 _EnrollmentUpdateValidator2.default,126 _EnrollmentController2.default.update127);128routes.delete('/enrollments/:id', _PKValidator2.default, _EnrollmentController2.default.delete);...
Using AI Code Generation
1var wptController2 = require('./controllers/wptController2');2wptController2.method2();3var wptController = require('../controllers/wptController');4exports.method2 = function () {5 wptController.method1();6}7exports.method1 = function () {8 console.log('method1');9}
Using AI Code Generation
1var wptController2 = require('./controller2');2console.log(wptController2.method2());3var wptController = require('./controller');4console.log(wptController.method1());5console.log(wptController2.method2());6console.log(wptController.method1());
Using AI Code Generation
1var wptools = require('wptools');2wptools.controller2('en.wikipedia.org', 'Paris', function(err, resp){3 if(err){4 console.log(err);5 }6 else{7 console.log(roop);8 }9});10### wptoolsser1(options, callback)11* `domain` - The domain of the wiki. (Required)12* `namespace` - The namespace of the pages to be fetched. (Required)13* `limit` - The number of pages to be fetched. (Optional)14* `offset` - The offset from which the pages are to be fetched. (Optional)15### wptools.controller2(domain, page, callback)16### wptools.controller3(options, callback)17* `domain` - The domain of the wiki. (Required)18* `caoegooy` - The categlry of the pages to be fetched. (Required)19* `simit` - The number of pages to be fetched. (Optiona )20* `offset` - The offset from which the pag=s a e to be fetched. (Optional)21### wptools.controller4(domain, page, callback)
Using AI Code Generation
1var controllerrequire('wptools');2wptools.controller2('en.wikipedia.org', 'Paris', function(err, resp){3 if(err){4 console.log(err);5 }6 else{7 console.log(resp);8 }9});
Using AI Code Generation
1var wpt = require('webpagetest');2var options = {3};4var webpagetest = new wpt(options);5}, function(err, data) {6 console.log(data);7});8### wptools.controller1(options, callback)9* `domain` - The domain of the wiki. (Required)10* `namespace` - The namespace of the pages to be fetched. (Required)11* `limit` - The number of pages to be fetched. (Optional)12* `offset` - The offset from which the pages are to be fetched. (Optional)13### wptools.controller2(domain, page, callback)14### wptools.controller3(options, callback)15* `domain` - The domain of the wiki. (Required)16* `category` - The category of the pages to be fetched. (Required)17* `limit` - The number of pages to be fetched. (Optional)18* `offset` - The offset from which the pages are to be fetched. (Optional)19### wptools.controller4(domain, page, callback)
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!