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

jsm-connector-interfaces

v1.0.5

Published

This project structure is inspired by Ruby on Rails and is designed to organize your NodeJS application efficiently.

Downloads

3

Readme

NodeJS Project Folder Structure

This project structure is inspired by Ruby on Rails and is designed to organize your NodeJS application efficiently.

Folder Structure

/app
├── config/
│   ├── sample.config.js
│   ├── index.js
├── database/
│   ├── sample.database.js
│   ├── index.js
├── routes/
│   ├── sample.routes.js
│   ├── index.ts
├── utils/
│   ├── sample.util.js
│   ├── index.js
├── middleware/
│   ├── sample.middleware.js
│   ├── index.js
├── models/
│   ├── sample.model.js
│   ├── index.js
├── controllers/
│   ├── sample.controller.js
│   ├── index.js
├── helpers/
│   ├── sample.helper.js
├── /server.js
/samples
├── .env.sample
/node_modules
/package.json
/.env

Project Structure Brief

Config & Sample

Configuration is divided into:

  • System Configuration
  • App Configuration
  • App Keys

Store configuration variables in .env files and commit only the structure with dummy values in the /samples folder.

Store the configuration variables in .env (dotenv) which are necessary for configuring your application like App Port, Environment (Production, Staging, etc.). .env configuration will be available across your app as they are set globally as ENV variables.

You could then create multiple app-relevant configuration files like:

  • Database Connection: Database-specific configurations like Host, Port & Name.
  • App Configuration: Acceptable Request Payload Size, Blacklisting IPs or Regions, etc.
  • Auth Configuration: OAuth Callback URLs, etc.

And last but not the least, you could create multiple files and store relevant keys, like OAuth Client & Secret Keys, Database Keys, Mailer Keys etc.

Important: Do not commit any of these configuration files to Git. Copy the configuration structure with dummy values and commit to git using sample files under the /sample folder.

Database

Manage your database connections (e.g., Redis, MongoDB) here. Include configuration and keys for initializing connections, handling events, etc.

Routes

Organize your routes into multiple files for scalability:

  • User Routes
  • Post Routes

Example:

const express = require("express");
const userRoutes = require("@routes/user.routes");
const postRoutes = require("@routes/post.routes");

app.use("/users", userRoutes);
app.use("/posts", postRoutes);

Utils

Utility functions, such as logging, which are static and unrelated to other classes/files.

Middleware

Middleware functions for tasks like body parsing, error handling, authentication, enabling CORS, and setting view engines.

Models

Each collection/table has a standalone model file. For example, user.model.js for user-related data operations.

Controllers

Controllers handle incoming requests, render pages, send JSON payloads, and perform API actions (POST, PUT, DELETE).

Helpers

Helpers are dynamic and related to specific controllers. They can parse user input, modify data before database storage, etc.

License

MIT