@noreajs/core
Advanced tools
Comparing version 1.1.0 to 1.1.1-0
@@ -1,7 +0,5 @@ | ||
import express from "express"; | ||
export { express }; | ||
export { default as group } from "./route/group"; | ||
export { RouteGroupParamsType, default as Route } from "./route/Route"; | ||
export { default as NoreaRouter } from "./route/NoreaRouter"; | ||
export { default as NoreaAppRoutes, NoreaAppRoutesInitMethods, } from "./route/NoreaAppRoutes"; | ||
export { default as Route } from "./route/Route"; | ||
export { NoreaApplication, RouteGroupParamsType, NoreaRouter, AppRoutesInitParamsType, BootstrapInitParamsType, } from "./interfaces"; | ||
export { AppRoutes, NoreaAppRoutes, group } from "./route"; | ||
export { NoreaApp, NoreaAppInitMethods } from "./NoreaApp"; | ||
export { NoreaBootstrap } from "./NoreaBootstrap"; |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const express_1 = __importDefault(require("express")); | ||
exports.express = express_1.default; | ||
var group_1 = require("./route/group"); | ||
exports.group = group_1.default; | ||
var Route_1 = require("./route/Route"); | ||
exports.Route = Route_1.default; | ||
var NoreaAppRoutes_1 = require("./route/NoreaAppRoutes"); | ||
exports.NoreaAppRoutes = NoreaAppRoutes_1.default; | ||
var route_1 = require("./route"); | ||
exports.AppRoutes = route_1.AppRoutes; | ||
exports.NoreaAppRoutes = route_1.NoreaAppRoutes; | ||
exports.group = route_1.group; | ||
var NoreaApp_1 = require("./NoreaApp"); | ||
exports.NoreaApp = NoreaApp_1.NoreaApp; | ||
var NoreaBootstrap_1 = require("./NoreaBootstrap"); | ||
exports.NoreaBootstrap = NoreaBootstrap_1.NoreaBootstrap; |
@@ -1,3 +0,5 @@ | ||
import NoreaRouter from "./NoreaRouter"; | ||
import NoreaRouter from "../interfaces/NoreaRouter"; | ||
import express from "express"; | ||
import NoreaApplication from "../interfaces/NoreaApplication"; | ||
import { RouteGroupParamsType } from "../interfaces"; | ||
/** | ||
@@ -9,3 +11,4 @@ * Group many routes to a single block | ||
*/ | ||
declare function group(middlewares: express.RequestHandler[], routes: (router: NoreaRouter) => void): import("express-serve-static-core").Router; | ||
export default group; | ||
export declare function group(middlewares: express.RequestHandler[], routes: (router: NoreaRouter) => NoreaRouter): NoreaRouter; | ||
export declare function routerGroup(this: NoreaRouter, prefixOrParams: string | RouteGroupParamsType, params?: RouteGroupParamsType): NoreaRouter; | ||
export declare function applicationGroup(this: NoreaApplication, prefixOrParams: string | RouteGroupParamsType, param?: RouteGroupParamsType): NoreaApplication; |
"use strict"; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) | ||
t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -21,2 +32,4 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
} | ||
// initialize group method | ||
expressRouter.group = routerGroup; | ||
// define routes | ||
@@ -26,2 +39,62 @@ routes(expressRouter); | ||
} | ||
exports.default = group; | ||
exports.group = group; | ||
function routerGroup(prefixOrParams, params) { | ||
var _a; | ||
/** | ||
* Extract parameters | ||
*/ | ||
const groupParams = (typeof prefixOrParams === "string" | ||
? params | ||
: prefixOrParams); | ||
const groupPrefix = typeof prefixOrParams === "string" ? prefixOrParams : undefined; | ||
// Params must always be merged | ||
const _b = (_a = groupParams.routerOptions, (_a !== null && _a !== void 0 ? _a : {})), { mergeParams } = _b, rest = __rest(_b, ["mergeParams"]); | ||
const expressRouter = express_1.default.Router(Object.assign({ mergeParams: true }, rest)); | ||
// add middlewares to router | ||
if (groupParams.middlewares && groupParams.middlewares.length != 0) { | ||
expressRouter.use(groupParams.middlewares); | ||
} | ||
// initialize group method | ||
expressRouter.group = routerGroup; | ||
// define routes | ||
groupParams.routes(expressRouter); | ||
// inject submodule | ||
if (groupPrefix) { | ||
this.use(groupPrefix, expressRouter); | ||
} | ||
else { | ||
this.use(groupPrefix, expressRouter); | ||
} | ||
return this; | ||
} | ||
exports.routerGroup = routerGroup; | ||
function applicationGroup(prefixOrParams, param) { | ||
var _a; | ||
/** | ||
* Extract parameters | ||
*/ | ||
const groupParams = (typeof prefixOrParams === "string" | ||
? param | ||
: prefixOrParams); | ||
const groupPrefix = typeof prefixOrParams === "string" ? prefixOrParams : undefined; | ||
// Params must always be merged | ||
const _b = (_a = groupParams.routerOptions, (_a !== null && _a !== void 0 ? _a : {})), { mergeParams } = _b, rest = __rest(_b, ["mergeParams"]); | ||
const expressRouter = express_1.default.Router(Object.assign({ mergeParams: true }, rest)); | ||
// add middlewares to router | ||
if (groupParams.middlewares && groupParams.middlewares.length != 0) { | ||
expressRouter.use(groupParams.middlewares); | ||
} | ||
// initialize group method | ||
expressRouter.group = routerGroup; | ||
// define routes | ||
groupParams.routes(expressRouter); | ||
// inject submodule | ||
if (groupPrefix) { | ||
this.use(groupPrefix, expressRouter); | ||
} | ||
else { | ||
this.use(expressRouter); | ||
} | ||
return this; | ||
} | ||
exports.applicationGroup = applicationGroup; |
@@ -1,16 +0,4 @@ | ||
import express from 'express'; | ||
import { Application } from "express"; | ||
import { AppRoutesInitParamsType } from "../interfaces"; | ||
/** | ||
* Type of parameter used to initialize the initializer of the application routes......., yes you get it | ||
*/ | ||
export declare type NoreaAppRoutesInitMethods = { | ||
/** | ||
* Filters that are applied before the application routes | ||
*/ | ||
middlewares: (app: express.Application) => void | undefined; | ||
/** | ||
* Application routes definition method | ||
*/ | ||
routes: (app: express.Application) => void; | ||
}; | ||
/** | ||
* Norea.Js app routes definitions, | ||
@@ -23,8 +11,8 @@ * Instantiate this class and define the different routes of your API | ||
*/ | ||
middlewares: (app: express.Application) => void | undefined; | ||
middlewares: (app: Application) => void | undefined; | ||
/** | ||
* Application routes definition method | ||
*/ | ||
routes: (app: express.Application) => void; | ||
constructor(init: NoreaAppRoutesInitMethods); | ||
routes: (app: Application) => void; | ||
constructor(init: AppRoutesInitParamsType<Application>); | ||
} |
@@ -1,9 +0,3 @@ | ||
import express from "express"; | ||
import * as core from "express-serve-static-core"; | ||
import NoreaRouter from "./NoreaRouter"; | ||
export declare type RouteGroupParamsType = { | ||
routerOptions?: express.RouterOptions; | ||
middlewares?: core.RequestHandler<core.ParamsDictionary, any, any, core.Query>[]; | ||
routes: (router: NoreaRouter) => void; | ||
}; | ||
import RouteGroupParamsType from "../interfaces/RouteGroupParamsType"; | ||
declare class Route { | ||
@@ -10,0 +4,0 @@ /** |
@@ -18,2 +18,3 @@ "use strict"; | ||
const express_1 = __importDefault(require("express")); | ||
const ExpressParser_1 = __importDefault(require("../helpers/ExpressParser")); | ||
class Route { | ||
@@ -28,3 +29,3 @@ /** | ||
const _b = (_a = params.routerOptions, (_a !== null && _a !== void 0 ? _a : {})), { mergeParams } = _b, rest = __rest(_b, ["mergeParams"]); | ||
const expressRouter = express_1.default.Router(Object.assign({ mergeParams: true }, rest)); | ||
const expressRouter = ExpressParser_1.default.parseRouter(express_1.default.Router(Object.assign({ mergeParams: true }, rest))); | ||
// add middlewares to router | ||
@@ -31,0 +32,0 @@ if (params.middlewares && params.middlewares.length != 0) { |
@@ -1,3 +0,3 @@ | ||
import { NoreaAppRoutes } from ".."; | ||
declare const _default: NoreaAppRoutes; | ||
import AppRoutes from "../route/AppRoutes"; | ||
declare const _default: AppRoutes; | ||
export default _default; |
@@ -6,13 +6,12 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const __1 = require(".."); | ||
const Route_1 = __importDefault(require("../route/Route")); | ||
exports.default = new __1.NoreaAppRoutes({ | ||
const AppRoutes_1 = __importDefault(require("../route/AppRoutes")); | ||
exports.default = new AppRoutes_1.default({ | ||
routes: (app) => { | ||
app.use("/api/v1", Route_1.default.group({ | ||
app.group("/api/v1", { | ||
middlewares: [ | ||
(req, res, next) => { | ||
return res.status(401).json({ | ||
message: "You are not allowed to access to this service", | ||
}); | ||
}, | ||
// (req: Request, res: Response, next: Function) => { | ||
// return res.status(401).json({ | ||
// message: "You are not allowed to access to this service", | ||
// }); | ||
// }, | ||
], | ||
@@ -36,4 +35,13 @@ routes: (module) => { | ||
}); | ||
module.group("/projects", { | ||
routes: (r) => { | ||
r.route("/all").get((req, res) => { | ||
res.status(200).send({ | ||
message: "All Projects", | ||
}); | ||
}); | ||
}, | ||
}); | ||
}, | ||
})); | ||
}); | ||
app.route("/dashboard").get((req, res) => { | ||
@@ -40,0 +48,0 @@ res.status(200).send({ |
@@ -7,13 +7,13 @@ "use strict"; | ||
const api_routes_1 = __importDefault(require("./api-routes")); | ||
const NoreaApp_1 = require("../NoreaApp"); | ||
const NoreaBootstrap_1 = require("../NoreaBootstrap"); | ||
/** | ||
* Create a new NoreaJs App | ||
*/ | ||
const app = new NoreaApp_1.NoreaApp(api_routes_1.default, { | ||
const bootstrap = new NoreaBootstrap_1.NoreaBootstrap(api_routes_1.default, { | ||
forceHttps: false, | ||
beforeStart: (app) => { }, | ||
afterStart: (app, server, port) => { | ||
console.log('App started'), | ||
console.log('Your app is running on port', port); | ||
} | ||
console.log("App started"), | ||
console.log("Your app is running on port", port); | ||
}, | ||
}); | ||
@@ -23,2 +23,2 @@ /** | ||
*/ | ||
app.start(3000); | ||
bootstrap.start(3000); |
{ | ||
"name": "@noreajs/core", | ||
"version": "1.1.0", | ||
"version": "1.1.1-0", | ||
"description": "Norea.Js is a sets of tools for the development of API with Node.Js.", | ||
@@ -38,6 +38,8 @@ "main": "dist/index.js", | ||
"@types/express": "^4.17.6", | ||
"@types/mailgen": "^2.0.3", | ||
"body-parser": "^1.19.0", | ||
"cors": "^2.8.5", | ||
"express": "^4.17.1" | ||
"express": "^4.17.1", | ||
"mailgen": "^2.0.13" | ||
} | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
41308
49
1049
7
2
6
5
+ Added@types/mailgen@^2.0.3
+ Addedmailgen@^2.0.13
+ Added@types/mailgen@2.0.7(transitive)
+ Addedansi-colors@4.1.3(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedasync@3.2.6(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedboolbase@1.0.0(transitive)
+ Addedbrace-expansion@1.1.112.0.1(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedcheerio@1.0.0-rc.10(transitive)
+ Addedcheerio-select@1.6.0(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedcommander@6.2.1(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedcss-select@4.3.0(transitive)
+ Addedcss-what@6.1.0(transitive)
+ Addeddom-serializer@1.4.1(transitive)
+ Addeddomelementtype@2.3.0(transitive)
+ Addeddomhandler@3.3.04.3.1(transitive)
+ Addeddomutils@2.8.0(transitive)
+ Addedejs@3.1.10(transitive)
+ Addedentities@2.2.0(transitive)
+ Addedescape-goat@3.0.0(transitive)
+ Addedfilelist@1.0.4(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedhe@1.2.0(transitive)
+ Addedhtmlparser2@5.0.16.1.0(transitive)
+ Addedjake@10.9.2(transitive)
+ Addedjuice@8.1.0(transitive)
+ Addedmailgen@2.0.29(transitive)
+ Addedmensch@0.3.4(transitive)
+ Addedmime@2.6.0(transitive)
+ Addedminimatch@3.1.25.1.6(transitive)
+ Addednode-fetch@2.7.0(transitive)
+ Addednth-check@2.1.1(transitive)
+ Addedparse5@6.0.1(transitive)
+ Addedparse5-htmlparser2-tree-adapter@6.0.1(transitive)
+ Addedslick@1.12.2(transitive)
+ Addedsupports-color@7.2.0(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedtslib@2.8.1(transitive)
+ Addedvalid-data-url@3.0.1(transitive)
+ Addedweb-resource-inliner@6.0.1(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwhatwg-url@5.0.0(transitive)