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

def-struct

v1.0.4

Published

This NPM package provides the default structure of the project with basic and needful redundant codes that are necessary in every project setup.

Downloads

6

Readme

def-struct

Size License GitHub package.json version npm version

This is a NPM package to render a new pre-configures app for building REST API's via the terminal. Download

Installation

install the npm package globally with following command.

npm i -g def-struct

Usage

Execute the following command in the directory where you want to scaffold the node REST API project.

npx def-struct

Answer the few basic questions and then you are ready to go!!!

? Provide a Project name # default - name of working directory
? Provide project version # default - 1.0.0
? Provide project description
? Enter authors name
? Choose a Package Manager # [NPM or Yarn]
? Want to initialize empty git
? Want dotenv module? 
? Choose the database module # [MongoDB, Mongoose or None]
? Initialise Prettier or EsLint?
? Want to initialize the linter?

Test the created application

nodemon server.js

NOTE

  • Default port for the application configured is 8080, so make sure the port is not busy.
  • To edit the port edit LISTENER_PORT in .env file.
  • Before executing this command on terminal make sure to provide the MongoDB connection URL (if choosen).
  • The DB_URL and DB_NAME in the .env file corresponds to MongoDB URL and Database name respectively.

Installed dependencies

Default Dependencies provided

  • express
  • body-parser
  • morgan
  • cors

Optinal Dependencies

  • dotenv
  • mongoose
  • mongoDB

Default devDependencies

  • nodemon

Folder structure

.
├── middlewares
    └── middleware.js
├── models
├── node_modules
├── routes
    └── helloworld.js
├── .env
├── .eslintrc.json
├── .gitignore
├── index.html
├── package.json
├── package-lock.json
├── prettier.config.js
└── server.js

Content of the files

server.js

const express = require("express");
const bodyParser=require("body-parser");
const morgan=require("morgan");
const cors = require("cors");

const app = express();

// Middlewares
app.use(cors({ origin: true, credentials: true }));
app.use(morgan("dev"));
app.use(bodyParser.urlencoded({extended:true}));
app.use(bodyParser.json());

//require Routes
const helloworld = require("./routes/helloworld");

app.use("/", helloworld);

app.listen(process.env.LISTENER_PORT, err=>{
    if(err){
        console.log(err);
    } else {
        console.log("Successfully started on port ",process.env.LISTENER_PORT);
    }
});

prettier.config.js

module.exports = {
    tabWidth: 1,
    semi: true,
    singleQuote: true,
    trailingComma: 'es5',
};

.eslintrc.json

{
    "env": {
        "node": true,
        "commonjs": true,
        "es2020": true
    },
    "extends": ["plugin:prettier/recommended", "airbnb-base"],
    "parserOptions": {
        "ecmaVersion": 11
    },
    "rules": {
        "prettier/prettier": "error"
    },
    "plugins": ["prettier"]
}

helloworld.js

const router=require("express").Router();
const path = require("path");

router.get('/',function(req,res){
    res.sendFile(path.join(path.dirname(__dirname) + "/index.html"));
});

module.exports = router;

Contributing

Contributions are welcome. We accept contributions via Pull Requests. :smile:

⚖ License

Copyright 2020 Ashutosh Srivastava. Licensed under the MIT License