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

frappe-backend

v1.1.27

Published

Frappe backend is a meta-data driven backend framework that enables rapid application development of Node.js REST API.

Downloads

6

Readme

Frappe-backend.js

Frappe backend is a meta-data driven backend framework that enables rapid application development of Node.js REST API. Inspired by frappejs a product from Frappe.

The objective of Frappe Backend is be a clean and opinionated micro-framework to develop small-business applications.

So, I love the simplicity of frappejs, and the Schema defined in the frappe framework to act as a Document Oriented framework, but using the power of a Relational Database Engine, what simplify and boost the level of coherence in the system.

Features

  • Rapid REST-API Development
  • Database backends

Quick Start


You can quickly get started with Typescript BoilerPlate


I you like to build it on your own, follow below guide:

Initialize a new NodeJS project

mkdir fback-demo && cd fback-demo npm init -y

Install Frappe Backend

npm i frappe-backend

add the Following to your package.json To start the server add this to your package.json

{
  ...
  "scripts": {
	"new-model": "frp-cmd new-model",
    "start": "frp-cmd start",
	"dev": "frp-cmd start dev"
  }
  ...
}

Create app Entry file for your project. e.g app.js and backend config file

const server = require('frappe-backend/server');

server.start({
  backend: 'pg', // To start a postgres backend.
  connectionParams: {
    db_name: process.env.DB_NAME, // Existing postgres database name
    username: process.env.DB_USERNAME, // Database username
    password: process.env.DB_PWD, // Database password
    host: process.env.DB_HOST, // Database host
    client: 'pg', // Database client. options are [pg]
  },
  enableCORS: true,
  //   models, // this will contain your database models
  // 	routes,
  // 	middlewareList: [testMid(124), testMid(5)],
});

Create frappe-backend.conf.js file at the root directory of your project. Minimum config look like:

module.exports = {
  dev: {
    devServerPort: process.env.PORT || 3000,
    devServerHost: 'localhost',
  },
  baseDir: '.', // If you want the model codes to be in another folder such as src
  useEs6: true, // If you want to generate models in ES6 Format
  node: {
    paths: {
      main: 'app.js',
    },
  },
  nodemon: {
    // To be able to run the development server
    watch: ['.'],
    ext: '.ts,.js',
    ignore: [],
    exec: 'ts-node',
    entry: './src/app.ts',
  },
};

To Generate your first Model(model is like database table). Example ToDo:

Now run npm run new_model ToDo This will create a new model in models/doctype called ToDo it will include a name field which represent the ID of each record. Go ahead and add the following fields under fields.: Read this to Understand more about models

{
	fieldname: 'subject',
	label: t`Subject`,
	placeholder: 'Subject',
	fieldtype: 'Data',
	required: 1,
},
{
	fieldname: 'status',
	label: t`Status`,
	fieldtype: 'Select',
	options: ['Open', 'Closed'],
	default: 'Open',
	required: 1,
},
{
	fieldname: 'description',
	label: t`Description`,
	fieldtype: 'Text',
},

Your ToDo.js Model should like this now:

module.exports = {
  name: 'ToDo',
  label: 'ToDo',
  naming: 'name', // {random|autoincrement}
  isSingle: 0,
  isChild: 0,
  isSubmittable: 0,
  settings: null,
  keywordFields: [],
  fields: [
    {
      fieldname: 'name',
      label: 'Name',
      fieldtype: 'Data',
      required: 1,
    },
    {
      fieldname: 'subject',
      label: t`Subject`,
      placeholder: 'Subject',
      fieldtype: 'Data',
      required: 1,
    },
    {
      fieldname: 'status',
      label: t`Status`,
      fieldtype: 'Select',
      options: ['Open', 'Closed'],
      default: 'Open',
      required: 1,
    },
    {
      fieldname: 'description',
      label: t`Description`,
      fieldtype: 'Text',
    },
  ],
};

Import models folder in your entry file

const server = require('frappe-backend/server');
const models = require('./models'); // Import Models folder
// import routes from './routes'; // Import Custom Routes
// import { testMid } from './middleware/sample.middleware';

server.start({
  backend: 'pg', // To start a postgres backend.
  connectionParams: {
    db_name: process.env.DB_NAME, // Existing postgres database name
    username: process.env.DB_USERNAME, // Database username
    password: process.env.DB_PWD, // Database password
    host: process.env.DB_HOST, // Database host
    client: 'pg', // Database client. options are [pg]
  },
  enableCORS: true,
  models, // Your Import
  // routes, // Your custom routing
  // middlewareList: [middleWare1, middleWare2], // Pass global middleware functions
});

Start Server

now run your server with npm run start. Your NodeJs Server will start at specified port. Go to your Postman and you should be able to consume RestAPI to your ToDo model. check this RestAPI Documentation

Documentation

Read the full docs

ToDo

  • [x] Allow custom Routes and overriding
  • [x] Add development nodemon reload/watch changes to files
  • [x] Pass custom Middleware to routes
  • [ ] Integrate various type of Authentication
  • [ ] Convert Package to Typescript

Contribution

You are welcome to contibute. Just raise the PR.

License

MIT