Giter Club home page Giter Club logo

labs-api-node-starter's Introduction

Basic Node API Scaffold

Welcome to your Basic Node API Repository. Use this to start your own Greenfield Project using nodejs, express and common industry standards.

This repository assumes a handful of industry practices and standards. We strive to keep you on the bleeding edge of the industry and as a result, we have made some opinions for you so that you don't have to; you're welcome.

Read more at https://docs.labs.lambdaschool.com/labs-api-strarter/

Maintainability Rating

Requirements

Labs teams must follow all Labs Engineering Standards.

Getting Started

Enviornment Variables

  • PORT - API port (optional, but helpful with FE running as well)
    • The following ports are whitelisted for use with okta
      • 3000
      • 8000
      • 8080
  • DS_API_URL - URL to a data science api. (eg. https://ds-bw-test.herokuapp.com/)
  • DS_API_TOKEN - authorization header token for data science api (eg. SUPERSECRET)
  • DATABASE_URL - connection string for postgres database
  • OKTA_URL_ISSUER - The complete issuer URL for verifying okta access tokens. https://example.okta.com/oauth2/default
  • OKTA_CLIENT_ID - the okta client ID.

See .env.sample for example values

Setup postgres

There are 3 options to get postgresql installed locally [Choose one]:

  1. Use docker. Install for your platform
    • run: docker-compose up -d to start up the postgresql database and pgadmin.
    • Open a browser to pgadmin and you should see the Dev server already defined.
    • If you need to start over you will need to delete the folder $ rm -rf ./data/pg as this is where all of the server data is stored.
      • if the database api-dev was not created then start over.
  2. Download and install postgresql directly from the main site
    • make note of the port, username and password you use to setup the database.
    • Connect your client to the server manually using the values previously mentioned
    • You will need to create a database manually using a client.
    • Make sure to update the DATABASE_URL connection string with the values for username/password, databasename and server port (if not 5432).
  3. Setup a free account at ElephantSQL
    • Sign up for a free Tiny Turtle plan
    • copy the URL to the DATABASE_URL .env variable
    • make sure to add ?ssl=true to the end of this url

Setup the application

  • create your project repo by forking or using this as a template.
  • run: npm install to download all dependencies.
  • run: cp .env.sample .env and update the enviornment variables to match your local setup.
  • run: npm run knex migrate:latest to create the starting schema.
  • run: npm run knex seed:run to populate your db with some data.
  • run: npm run tests to confirm all is setup and tests pass.
  • run: npm run watch:dev to start nodemon in local dev enviornment.

Make sure to update the details of the app name, description and version in the package.json and config/jsdoc.js files.

Contributing

See the contributing doc for more info.

labs-api-node-starter's People

Contributors

ashtilawat23 avatar benhall-7 avatar bummings avatar clydefrog04 avatar danielreinagel avatar dependabot[bot] avatar ryan-hamblin avatar tinomen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

labs-api-node-starter's Issues

Add message to keep last part of sample url

We were given a url specific for our project, that didn't include the /oauth2/default part. Copying and pasting the url that we given resulted in an error. Then we realized that we needed to stick /oauth2/default to our url. We recommend adding a message that lets users know that /oauth2/default needs to be part our the variable in the .env

Pattern of url we were given: Okta URI: https://blah.okta.com

Complete url needed:
OKTA_URL_ISSUER=https://example.okta.com/oauth2/default

Add 'run' to instruction in README for using nodemon

The current line about nodemon in the README is:
run: npm watch:dev to start nodemon in local dev enviornment.

When we used it, it was not successful at starting the local server.
However,

npm run watch:dev

was successful at starting the local server.
We suggest adding 'run' to that line of instructions.

README could use a step for using nodemon

Currently the last step is:
run: npm start to start your local development server.

It would be really helpful to have a step about using nodemon instead, so that the users won't need to remember to restart the server as changes are made. I've noticed that there is a script in package.json:
"watch:dev": "nodemon",

Would that work similarly to a script like "server": "nodemon server.js", or is the watch:dev script used in conjunction with the
"start": "node server.js"?

'npm run format' error

Running 'npm run format' from 'CONTRIBUTING.md results in "'jsx' is not recognized as an internal or external command, operable program or batch file." This error occurred on my Microsoft Windows 10 Pro as well as @ryan-hamblin 's set up. Error may be related to Husky in package.json
image

response body of DELETE profile doesn't return the profile info

https://github.com/Lambda-School-Labs/labs-api-starter/blob/0b14cc48214b503c04832a98dda77800d213da80/api/profile/profileRouter.js#L284

Not a big deal, but I believe that when a delete happens, the number of rows affected is returned, not the row itself:

From http://knexjs.org/#Builder-del%20/%20delete

del / delete โ€” .del()
Aliased to del as delete is a reserved word in JavaScript, this method deletes one or more rows, based on other conditions specified in the query. Resolves the promise / fulfills the callback with the number of affected rows for the query.

The current setup for the DELETE route returns a property of profile with its value being what is returned. The swagger docs show that a profile is expected.

  •            profile:
    
  •              $ref: '#/components/schemas/Profile'
    

However, a 1 would be the expected response upon a successful deletion.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.