0.0.5 • Published 2 years ago

nodra v0.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Nodra

MIT License

Rate this package

build: passing

Nodra is a public npm package that will help you to create and configure a custom backend node based CRUD application in minutes

Installation

Install Nodra with npm

  npm install -g nodra
  nodra create-server

Features

Nodra provide you wide range features to setup a custom backend for your web application

  • Database Connectivity
  • Schema Validation
  • Ready to use API
  • Template engine
  • Authentication & Authorization
  • Static website

Folder Structure

server
├── node_modules
├── api
│   └── user.js
├── db
│   └── conn.js
├── middlewares
│   └── auth.js
├── models
│   └── schema.js
├── public
│   ├── css
│   ├── js
│   └── images
├── routes
│   └── route.js
├── temp
│   ├── partials
│   └── views  
├── .env
└── package.json

Site Map

ActionPathRequestDescription
Static fileshttp://localhost:3000/user/publicGETthis endpoint contains static files like css, js, images etc.
Createhttp://localhost:3000/user/registerPOSTThis endpoint get user data, validate schema and create a user in database.
Updatehttp://localhost:3000/user/update/idPOSTThis endpoint get user data along user ID and update the user data in database.
Deletehttp://localhost:3000/user/deletePOSTThis endpoint get get user data along user ID, verify password and delete the user.
Loginhttp://localhost:3000/user/loginPOSTThis endpoint get user credentials, verify it, check authorization and redirect to user panel.
Logouthttp://localhost:3000/user/logoutGETThis endpoint is just logout the user If that user is logged in.

How do I setup my app?

  • Configure Enviromental variable

    • Open .env file, modify secret values or remain it default.
    • DB contain mongodb endpoint, PORT number used for node app, SECRET is for Auth token generation, STATIC concat value with app endpoint.
  • Move Static files

    • Navigate to Public folder, move files in css, js, images folders.
    • Modify your paths in html files and got to endpoint : http://localhost:3000/public/
  • Move Dynamic files

    • Navigate to temp folder, move handlebars (hbs) files in views folder
    • Move components / parts of website in partial folder which are frequently used.
    • Modify paths of handlebar files and link css, js, images files with template engine.
  • Set Routes

    • Go to routes folder, route files contains main routes of node app.
    • You can create more routes according to need like contact us, login, register etc.
    • In user panel route, give the name of user dashboard from template engine files. Note : Dashboard will open after successfull Authentication.
  • Manage API

    • Jump to API folder, user.js file contains all user actions like registeration, updation, deletion etc.
    • Convert all res.json to res.render to render data in template engine pages.
  • Modify Schema

    • By default, there's user schema to valide data but you modify it and add more schemas for different collections.

What Next ?

Nodra is a complete backend solution for web developers but what about frontend ? Is there any way ?

Well, there are multiple ways to integrate node app with different frontends but currently main are two:

  • Using Template Engine :

    Template Engine like hbs, ejs are easy to integrate with Node for sending and receiving data in both ways. No prior knowledge is required, fast development and easy to setup and efficient for small projects.

  • Using React JS :

    React JS is one of the best frontend framework and part of MERN development. It provides you an awesome frontend using rich css libraries. Prior knowledge is required, a little bit difficult to setup, best for huge projects and it takes a lot of time.

Authors

Bilal Ahmad

License

MIT

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago