Socket
Socket
Sign inDemoInstall

@marble-seeds/api

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@marble-seeds/api

## Install with


Version published
Maintainers
1
Created
Source

Marble seeds api

Install with

npm i @marble-seeds/api

Docs

Server

To create a server do

const { server } = require('marble-api')
const routers = require('./routers')

const apiPort = 3000
const app = server()

routers.add(app)

app.listen(apiPort)
console.log(`Api started: <${apiPort}>`)

This server is a config version of Koa

Routers

To create a router/route do

const { Router, Route } = require('marble-api')

const status = new Route({
  method: 'get',
  path: '/',
  handler: async function (ctx) {
    ctx.body = {
      success: true,
      requested: new Date()
    }
  }
})

module.exports = new Router({
  routes: [status],
  prefix: '/status'
})

To have multiple routers on you app do

const { Router } = require('marble-api')

const status = require('./status')
const webhooks = require('./webhooks')

const routers = new Router({
  routes: [status, webhooks],
  prefix: '/api'
})

module.exports = routers
To-Dos
  • Refactor clone on router.js and forEach on route.js to remove lodash dependency
  • Remove any type
  • Add test for plug task
  • Add test for nested routers
  • Refactor to remove _isRoute and _isRouter.

FAQs

Package last updated on 25 Feb 2024

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

  • 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