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

faap

v0.2.4

Published

Fast Api for Any Prototype

Downloads

12

Readme

faap

Travis CI status Deploy

Fast Api for Any Prototype (like postgrest, but you don't need create schema manually)

Allows via rest api add, edit, sort, filter any arbitrary data sets. What is convenient when creating demos and prototypes, since there is no need to write server api, models, migrations, etc.

There is a built-in authorization by token, or you can connect to an existing one.

Included data generation tool.

Example

Example app

Swagger Api Docs

Local http://localhost:3200/faap/v1/docs/swagger

Remote https://faap-app.herokuapp.com/faap/v1/docs/swagger

Run

Express extension

Simple usage:

const path = require('fs')
const faap = require('faap')

const app = express()

app.use(faap({
   MONGO_URL: 'mongodb://localhost:27017/test',
   UPLOADS_ENABLED: true,
   UPLOADS_DIR: path.join(__dirname, 'uploads'),
   SWAGGER_UI_ENABLED: true,
   ENABLE_TOOLS: true
}))

Advanced usage:

const faap = require('faap')

const app = express()

// optional, below are the default values
const config = {
  // for example: 'mongodb://localhost:27017/test'
  MONGO_URL: null,

  // set url, faap send GET response to that url
  // with all headers and if credentials invalid, send any http code out of the range of 2xx
  CHECK_AUTH_URL: null,
  // if true, you can login/register/edit profile at site
  INNER_AUTH_ENABLED: false,
  // where save users data
  INNER_AUTH_COLLECTION: 'user',
  INNER_AUTH_SALT: 'w@N:X+nG Fhu!N~PW|>,Wyl1M8)4[&so1-=&Pd8aO+wkIn;,:;gi4n<+aZGH-|.Q',

  // max size of json content which sended my client
  BODY_SIZE_LIMIT: '4mb',

  BASE_API_PATH: '/faap/v1/',

  // show in console.log('Created collection with id...')
  SHOW_DEBUG_MSG: false,

  // if true on /faap/v1/docs/swagger you can see swagger ui
  SWAGGER_UI_ENABLED: false,

  // enable upload files
  UPLOADS_ENABLED: true,
  // where saved uploaded files
  // for example: path.join(__dirname, 'uploads')
  UPLOADS_DIR: null,
  UPLOADS_ACCEPTED_MIMES: ['image/png', 'image/jpeg', 'image/pjpeg', 'image/gif', 'text/plain'],
  UPLOADS_SIZE_LIMIT: 4 * 1024 * 1024,
  
  // enable tools for admin collections (truncate, gen fake data and etc)
  ENABLE_TOOLS: false
}

// optional, set you auth and db
const callbacks = {
  getDB: async (config) => await mongoClient.connect(mongoUrl),
  checkIdentify: async (request, config, db) => isLogged ? true : Promise.reject(new Error('Not authorized')),
  transformList: ({data, _meta, _links}, collectionName, req) => ({data, _meta, _links}),
  transformItem: (item, collectionName, req) => item,
  validateRequest: async (request, config, db, auth) => {
    await auth.isLoggedUser()
    return enableValidate === false || (auth.user && auth.user.foo === request.body.foo)
      ? true
      : Promise.reject({foo: 'you cant change foo'})
  }
}

app.use(faap(config, callbacks))

Heroku

Use deploy button or:

  1. Create new app
  2. Fork repo and add to app
  3. Enable metadata support:
heroku labs:enable runtime-dyno-metadata -a you_app_name
  1. Get free mongodb on https://mlab.com/ and create new db or set you mongo url
  2. Set db config:
heroku config:set MONGO_URL="mongodb://user:pass@host:port/dbname" -a you_app_name
  1. Set other configs if need via enviroment avalibled in serverConfig.js
// enabling swager ui
heroku config:set SWAGGER_UI_ENABLED=true -a you_app_name
  1. ???
  2. Profit!

Docker image

docker run -d -p 3200:3200 --name faap --restart always grinat0/faap

With enable auth

docker run -d -p 3200:3200 -e "USE_INNER_AUTH=true" --name faap --restart always grinat0/faap

With you auth url (all headers was sent to that url by get response)

docker run -d -p 3200:3200 -e "CHECK_AUTH_URL=http://loc/check-auth.php" --name faap --restart always grinat0/faap

Dev

# run db
cd docker/dev && docker-compose up

# run hot reload server
npm i && npm run dev

Prod

Docker compose

cd docker/prod && docker-compose up

Or build docker file and run

docker run -p 3200:3200 faap

Build

Build docker file

docker build -t faap .

Testing

With docker

cd docker/test && docker-compose up --abort-on-container-exit

Local (need running db)

npm run test