Socket
Socket
Sign inDemoInstall

rest-api.hl

Package Overview
Dependencies
63
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 1.0.2

1

lib/index.d.ts

@@ -13,2 +13,3 @@ export interface Option {

}
export declare function generateRestAPI<T>(service: RestService<T>): any;
//# sourceMappingURL=index.d.ts.map
"use strict";
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());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildOptions = void 0;
exports.generateRestAPI = exports.buildOptions = void 0;
const express_1 = __importDefault(require("express"));
function buildOptions(val, desc) {

@@ -9,2 +22,32 @@ return { val: val, desc: desc };

;
function generateRestAPI(service) {
const route = express_1.default.Router();
route
.route("/")
.get((req, res, next) => __awaiter(this, void 0, void 0, function* () {
const items = yield service.getAll();
res.send(items);
}))
.post((req, res, next) => __awaiter(this, void 0, void 0, function* () {
const result = yield service.post(req.body);
res.send(result);
}));
route.route("/options").get((req, res, next) => __awaiter(this, void 0, void 0, function* () {
res.send(yield service.options());
}));
route
.route("/:id")
.get((req, res, next) => __awaiter(this, void 0, void 0, function* () {
const item = yield service.get(+req.params.id);
res.send(item);
}))
.put((req, res, next) => __awaiter(this, void 0, void 0, function* () {
const id = +req.params.id;
const result = yield service.put(Object.assign({ id }, req.body));
res.send(result);
}));
return route;
}
exports.generateRestAPI = generateRestAPI;
;
//# sourceMappingURL=index.js.map

8

package.json
{
"name": "rest-api.hl",
"version": "1.0.1",
"version": "1.0.2",
"description": "",

@@ -8,3 +8,4 @@ "main": "lib/index.js",

"scripts": {
"build": "tsc -p ."
"build": "tsc -p .",
"pb": "npm run build && npm publish"
},

@@ -25,3 +26,6 @@ "repository": {

"typescript": "^4.2.4"
},
"dependencies": {
"express": "^4.17.1"
}
}

Sorry, the diff of this file is not supported yet

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