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

projects-api

v1.0.0

Published

Microservice for onboarding of new users and creation of new Projects

Downloads

2

Readme

Hi, welcome to the "projects-api" repo. Please use this readme as an introduction to get you started on working with this repo.

Table of Contents

  1. Get Started
  2. Routes
  3. File Structure
  4. Error Handling
  5. Additional Info

Additional info can also be found in the Engineering Wiki section of Notion.


Get Started

To get started, please follow these instructions:

  1. Ensure you have the .env file set up. Please place it in the root directory of this repo (same directory-level as this README.md)

  2. Check the package.json and make sure your PORT is configured properly. It should read:

  // Located in package.json, 'scripts', 'start'
  // for PORT=30##, # can be any integer from 0-9. (i.e. 3004)

  // Windows
  set PORT=30## && react-scripts start

  // Mac & Unix
  PORT=30## react-scripts start

You should probably make sure this is the same PORT used in the other projects when they need to refer to this repo.

  1. Make sure that you have access to Naya npm packages. Login with same email using npm login.

  2. Install dependencies using npm install or yarn install

  3. Run with npm start or yarn start to start in production environment, Run with npm run dev or yarn run dev to start in development environment


Routes

For information about all the CRUD actions you can perform in this repo, please refer to our wiki.


File Structure

Here are some of the folders/files we will talk about in this section:

  repo
   |--> actions/
   |--> middlewares/
   |--> models/
   |--> routes/
   |--> services/
   |--> .env

There are other folders and files found in this repo (such as src/public/) that will not be discussed in this chapter (most of them are used for configuration)

Folders and Files

Here we will go over the general purposes for each of the folder/file (mentioned above).

  1. actions/

      src
      |--> actions/

    This folder is used to contain all the side-effect actions that occur from a route. It is common to have CRUD requests to other APIs in this folder.

    Example: After an ecosystem user has updated their estimation, we would want to email an admin about this update. This folder will contain the logic used to send the email.

  2. middleware/

      src
      |--> middleware/

    This folder is used to contain all custom middlewares used in this repo. For middleware initialization from external packages (npm), please initialize in the 'services' folder.

  3. models/

      src
      |--> models/

    This folder is used to contain all the Mongoose schema's used throughout this repo. If necessary, sub-directories can be created for organization purposes.

  4. routes/

      src
      |--> routes/

    This folder contains all routes available from this repo. If necessary, sub-directories can be created for organization purposes.

    NOTE: Before writing a new route, please refer to the wiki and see if there are existing routes that will satisfy your requirements.

  5. services/

      src
      |--> services/

    This folder contains all external service initialization. (i.e. Firebase-admin, SendGrid)

  6. .env

     repo
      |--> .env

    .env is for our sensitive constants, you can find a copy for local usage in our Notion


Error Handling

All errors that occurs in a route should return a response with this template. You can extend this template and add additional fields but this is the bare minimum.

{
  status: false,
  message // describes why the request failed
}

The message should be of type string and should be descriptive enough to highlight the problem with the developer's request. The message can also provide hints for the developer on how to fix their request.

As a rule of thumb, there should be error messsages if:

  • a request payload is missing required fields
  • failed database query
  • failed validation check of any data (i.e. non-valid email is provided for a sign-up)

Also remember to return your error messages if it is not at the end of a closure.


if (!user) // this will throw an error
  res.json({ status: false, message: 'No user found with the provided credentials. Invalid email/uid' })


if (!user) // this will not throw an error
  return res.json({ status: false, message: 'No user found with the provided credentials. Invalid email/uid' })

TODO: Standardize status codes? Do we even need status codes as it's redundant?


Additional Info

Here are some helpful links to wikis that cover topics missed in this readme:

Dependencies

TBD? What rules for dependencies?