Socket
Socket
Sign inDemoInstall

arrow-express

Package Overview
Dependencies
71
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.4 to 0.1.5

dist/application/application.d.ts

0

.eslintrc.js

@@ -0,0 +0,0 @@ // eslint-disable-next-line no-undef

@@ -45,2 +45,3 @@ "use strict";

this._express = app;
this._started = false;
this.port = port;

@@ -111,2 +112,15 @@ }

/**
* Register controller in application.
* @param controllers - controllers to register
*/
AppConfigurator.prototype.registerControllers = function () {
var _this = this;
var controllers = [];
for (var _i = 0; _i < arguments.length; _i++) {
controllers[_i] = arguments[_i];
}
controllers.forEach(function (controller) { return _this.registerController(controller); });
return this;
};
/**
* Starts application, register controllers routes in express app

@@ -117,2 +131,6 @@ * and connect to configured port

var _this = this;
if (this._started) {
throw new Error('Cannot start application multiple times');
}
this._started = true;
this._controllers.forEach(function (controller) {

@@ -119,0 +137,0 @@ controller.getRoutes().forEach(function (route) {

71

dist/application/Application.spec.js

@@ -43,3 +43,3 @@ "use strict";

var request_error_1 = require("../error/request.error");
var ts_jest_1 = require("ts-jest");
var utils_1 = require("ts-jest/utils");
var ExpressAppStub = {

@@ -53,27 +53,34 @@ use: jest.fn(),

afterEach(function () {
ts_jest_1.mocked(ExpressAppStub.use).mockReset();
ts_jest_1.mocked(ExpressAppStub.post).mockReset();
ts_jest_1.mocked(ExpressAppStub.get).mockReset();
utils_1.mocked(ExpressAppStub.use).mockReset();
utils_1.mocked(ExpressAppStub.post).mockReset();
utils_1.mocked(ExpressAppStub.get).mockReset();
});
describe('route registration', function () {
it('should register post route', function () {
var handlerSpy = jest.fn();
application_1.Application({ port: 8080, app: ExpressAppStub })
.registerController(controller_1.Controller()
.prefix('prefix')
.registerRoute(route_1.Route()
.method('post')
.path('path')
.handler(handlerSpy))).start();
expect(ExpressAppStub.post).toHaveBeenCalledWith('/prefix/path', expect.any(Function));
describe('start', function () {
it('should throw error if app is started multiple times', function () {
var testApplication = application_1.Application({ port: 8080, app: ExpressAppStub });
testApplication.start();
expect(testApplication.start).toThrow();
});
it('should register get route', function () {
var handlerSpy = jest.fn();
application_1.Application({ port: 8080, app: ExpressAppStub })
.registerController(controller_1.Controller().prefix('prefix')
.registerRoute(route_1.Route()
.method('get')
.path('')
.handler(handlerSpy))).start();
expect(ExpressAppStub.get).toHaveBeenCalledWith('/prefix', expect.any(Function));
describe('route registration', function () {
it('should register post route', function () {
var handlerSpy = jest.fn();
application_1.Application({ port: 8080, app: ExpressAppStub })
.registerController(controller_1.Controller()
.prefix('prefix')
.registerRoute(route_1.Route()
.method('post')
.path('path')
.handler(handlerSpy))).start();
expect(ExpressAppStub.post).toHaveBeenCalledWith('/prefix/path', expect.any(Function));
});
it('should register get route', function () {
var handlerSpy = jest.fn();
application_1.Application({ port: 8080, app: ExpressAppStub })
.registerController(controller_1.Controller().prefix('prefix')
.registerRoute(route_1.Route()
.method('get')
.path('')
.handler(handlerSpy))).start();
expect(ExpressAppStub.get).toHaveBeenCalledWith('/prefix', expect.any(Function));
});
});

@@ -101,3 +108,3 @@ });

.handler(spy))).start();
return [4 /*yield*/, ts_jest_1.mocked(ExpressAppStub.get).mock.calls[0][1]({}, resSpy)];
return [4 /*yield*/, utils_1.mocked(ExpressAppStub.get).mock.calls[0][1]({}, resSpy)];
case 1:

@@ -122,3 +129,3 @@ _a.sent();

.handler(spy))).start();
return [4 /*yield*/, ts_jest_1.mocked(ExpressAppStub.get).mock.calls[0][1]({}, resSpy)];
return [4 /*yield*/, utils_1.mocked(ExpressAppStub.get).mock.calls[0][1]({}, resSpy)];
case 1:

@@ -144,3 +151,3 @@ _a.sent();

.handler(spy))).start();
return [4 /*yield*/, ts_jest_1.mocked(ExpressAppStub.get).mock.calls[0][1]({}, resSpy)];
return [4 /*yield*/, utils_1.mocked(ExpressAppStub.get).mock.calls[0][1]({}, resSpy)];
case 1:

@@ -165,3 +172,3 @@ _a.sent();

.handler(spy))).start();
return [4 /*yield*/, ts_jest_1.mocked(ExpressAppStub.get).mock.calls[0][1]({}, resSpy)];
return [4 /*yield*/, utils_1.mocked(ExpressAppStub.get).mock.calls[0][1]({}, resSpy)];
case 1:

@@ -185,3 +192,3 @@ _a.sent();

.handler(spy))).start();
return [4 /*yield*/, ts_jest_1.mocked(ExpressAppStub.get).mock.calls[0][1]({}, resSpy)];
return [4 /*yield*/, utils_1.mocked(ExpressAppStub.get).mock.calls[0][1]({}, resSpy)];
case 1:

@@ -205,3 +212,3 @@ _a.sent();

.handler(spy))).start();
return [4 /*yield*/, ts_jest_1.mocked(ExpressAppStub.get).mock.calls[0][1]({}, resSpy)];
return [4 /*yield*/, utils_1.mocked(ExpressAppStub.get).mock.calls[0][1]({}, resSpy)];
case 1:

@@ -229,3 +236,3 @@ _a.sent();

.handler(spy))).start();
return [4 /*yield*/, ts_jest_1.mocked(ExpressAppStub.get).mock.calls[0][1]({}, resSpy)];
return [4 /*yield*/, utils_1.mocked(ExpressAppStub.get).mock.calls[0][1]({}, resSpy)];
case 1:

@@ -252,3 +259,3 @@ _a.sent();

.handler(spy))).start();
return [4 /*yield*/, ts_jest_1.mocked(ExpressAppStub.get).mock.calls[0][1]({}, resSpy)];
return [4 /*yield*/, utils_1.mocked(ExpressAppStub.get).mock.calls[0][1]({}, resSpy)];
case 1:

@@ -255,0 +262,0 @@ _a.sent();

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ // eslint-disable-next-line no-undef

@@ -0,0 +0,0 @@ // eslint-disable-next-line no-undef

@@ -0,0 +0,0 @@ {

@@ -0,0 +0,0 @@ # This is example application

@@ -0,0 +0,0 @@ import {RequestError} from "arrow-express";

@@ -0,0 +0,0 @@ import {Route, RouteConfigurator} from "arrow-express";

@@ -0,0 +0,0 @@ import {Route, RouteConfigurator} from "arrow-express";

@@ -0,0 +0,0 @@ import {Controller, ControllerConfiguration, RouteConfigurator} from "arrow-express";

@@ -0,0 +0,0 @@ import { User } from '../entities/user.entity';

@@ -0,0 +0,0 @@ // Express packages

@@ -0,0 +0,0 @@ {

@@ -0,0 +0,0 @@ // eslint-disable-next-line no-undef

@@ -0,0 +0,0 @@ import { Application } from './application';

@@ -0,0 +0,0 @@ import Express from 'express';

@@ -0,0 +0,0 @@ import {Route} from "../route/route";

@@ -0,0 +0,0 @@ import {RouteConfigurator} from '../route/route';

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ export { Application, AppConfigurator } from "./application/application";

@@ -0,0 +0,0 @@ import { Route } from './route';

@@ -0,0 +0,0 @@ import Express from 'express';

{
"name": "arrow-express",
"version": "0.1.4",
"version": "0.1.5",
"description": "Library to bootstrap express applications with zero configuration",
"main": "dist/index.js",
"types": "lib/index.d.ts",
"types": "dist/index.d.ts",
"directories": {

@@ -11,3 +11,3 @@ "lib": "lib"

"scripts": {
"build": "tsc",
"build": "tsc --declaration",
"test": "test",

@@ -14,0 +14,0 @@ "test:watch": "jest --watch",

@@ -0,0 +0,0 @@ # Arrow Express

@@ -0,0 +0,0 @@ {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc