npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ark-rest

v1.0.0

Published

Create full CRUD REST API with no code at all.

Downloads

48

Readme

ARK REST Server

Create full ACTUAL REST API's with Express server without actually writing backend code. This package provides a simple and easy-to-use setup for creating an Express server without actually coding backend.

It allows you to quickly get started with building web applications backed by a MongoDB database. You just need to know mongodb. That's it.

Table of content

Getting started

npm i ark-rest       # Install package
npx ark-rest init .  # Initialize project
npx ark-rest         # Start server. Demo server will start.

See ark.config.yaml for more details

Module

If you need to create schemas, models or need instance of express server and express app they can be used like following. No need to install mongodb and express packages.

const {
	Express,       // Express module instance
	server,        // Express app instance
	Schema,        // Instance of mongodb schema
	Model,         // Instance of mongodb model
} = require('ark-rest/exports');

CLI Usage

npx ark-rest [options] <source>

Options:
      --version  Show version number                                   [boolean]
      --config   Path to JSON config file
      --init     Initialize a new ark project                          [boolean]
  -p, --path     Path to folder containing ark config file
  -d, --dev      Run in development mode
  -w, --watch    Watch file(s)                                         [boolean]
  -q, --quiet    Suppress log messages from output                     [boolean]
      --help     Show help                                             [boolean]

Ark Config in detail

schemas:              # Array
    - id: /route-name # Ex: /, /user, /product
      collection: mongodb-collection-name
      schema: './path/to/schema'

config:
    db: mongodb
    url: mongodb://localhost:27017/   # Able to connect to Atlas

server:
    port: 3000 # Defaults to 6666
    cors:
        origin: 'localhost:3000'
        optionsSuccessStatus: 200
        methods: 'POST,PUT'
        allowedOrigins: ['localhost:3000']
        # ... all CORS options accepted by CORS middleware

    auth:                                # Uses JWT for validation
        enabled: true                    # Defaults to false
        # protected: 'all'
        schema: './path/to/schema' # Auth schema
        cookieExpire: 3600               # in seconds default: 15min
        secret: 'mysecret'               # required

        # Following 2 blocks are optional.
        # They are needed when you want to implement your own auth functions.
        # Just export function named with param (req, res, next)
        routesFilePath: './path/to/function/file.js'
        routes:
            - login:
                  route: '/logintest'
                  method: GET
                  middlewareFn: fn
                  functionName: fnName

    # Routes which can not be created with help of schemas
    extendRoutes:
        routesFilePath: './path/to/function/file.js'
        routes:
            - route: '/example'
              method: GET
              functionName: exampleGet

    # To enable logging when request is made using morgan
    logging:
        enabled: true   # Defaults to false
        query: :id      # Defaults to :remote-addr :method :url :response-time
        tokenFunctions: #  Optional
            - id: id
              functionName: mongooseId
              functionPath: './path/to/function/file.js'
            - id: tokenId
              functionName: functionName
              functionPath: functionPath

License

This module is open-source and available under the MIT License.