Socket
Book a DemoInstallSign in
Socket

@kolinalabs/api-pack-mongoose

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kolinalabs/api-pack-mongoose

Mongoose helpers for nodejs-api-pack

1.1.2
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Api Pack - Mongoose

Mongoose helpers for nodejs-api-pack

Official Documentation

Usage

Installation

// npm
$ npm install @kolinalabs/api-pack-mongoose

// or yarn
$ yarn add @kolinalabs/api-pack-mongoose

Basic example (with api-pack-express)

Api pack express provides the default stack for running nodejs-api-pack with the ExpressJS framework.

$ yarn add @kolinalabs/api-pack-express

Configure Model(s)

const mongoose = require("mongoose");

const TaskSchema = new mongoose.Schema({
  title: String,
  status: String,
  priority: Number,
  closed: Boolean,
  openedAt: Date,
  closedAt: Date
});

const Task = mongoose.model("Task", TaskSchema);

Init ApiPack

const { ApiPack } = require("@kolinalabs/api-pack-mongoose");

// Using @kolinalabs/api-pack-express router stack
const ApiPackExpress = require("@kolinalabs/api-pack-express");

const apiPack = new ApiPack([
  Task
  // other models...
]);

const routes = apiPack.routing(ApiPackExpress);

const app = express();
app.use(bodyParser.json());
app.use("/api", routes);

app.listen(3003);

Access the URLs

GET: http://localhost:3003/api/tasks

POST: http://localhost:3003/api/tasks

GET: http://localhost:3003/api/tasks/:id

PUT: http://localhost:3003/api/tasks/:id

DELETE: http://localhost:3003/api/tasks/:id

Other examples

FAQs

Package last updated on 15 May 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.