Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@noreajs/core

Package Overview
Dependencies
Maintainers
1
Versions
92
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@noreajs/core - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1-0

dist/helpers/ExpressParser.d.ts

10

dist/index.d.ts

@@ -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;

9

dist/route/group.d.ts

@@ -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"
}
}
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc