Sunteți pe pagina 1din 2

1) npm init - y for our package.

json
2) yarn add nodemon --dev (only for development) so that we can auto load the
server on change
3) make sure to go into package.json, add new script called "server" or w/e
3b) add one more for production called "start"
4) make the "start" command -> "node index.js"
make the "server" command -> "nodemon index.js"
5) add index.js
6) add in our dependencies (at the very least, express, knex, and sqlite3)
(maybe morgan, cors, helmet)
(for sessions and auth: bcryptjs, connect-session-knex, dotenv, express-session,
jsonwebtoken)

7) terminal command knex init to get our knexfile.js


8) go in, remove production and staging for now, and add useNullAsDefault: true in
our connection
8b) Slingtly optional -> add in migrations and seeds and point them to the data
folder. throw in
the db.sqlite3 file into there too!
9) Finally, change the name of the filename to desired database name
10) optional: .env files for hiding certain development stuff like secrets
10b) dont forget to add .env on its own line in .gitignore

This should be all for setting up the files for code. For code, take a look at prev
projects. All
middleware needs to be added in and required, and then add endpoints. use
server.listen to check
if the server is responding and live.

// maybe put all this code into a data folder, along with my database!
For knex migrations:

1) ...knex migrate: make some_database


2) after building out the database with your tbl methods, don't forget the
rollback.
3) use knex migrate:latest to run your database
4) optional: make a quick knex seed:make some_seeding_algorithim and knex seed:run
to seed some stuff in
5) add some helpers in and some middleware and routes if necessary (optional, but
makes the
code a lot cleaner and readable - i do it when i have stretch time
6) DEFINITELY think about putting all your routes and middleware in seperate
folders
7) if this is personal use api, then no need a login, but that's the next step for
a full stack

thats it mostly for databases, and writing out your routes is the end of the road
for the api

//add section for heroku implementation!

// adding security for your routes


1) okay, first we need to have

now front-end with react:

1) create-react-app client
2) add a bunch of dependencies (MAKE SURE TO CD INTO THE CLIENT LOL)
3) yarn add react-router react-router-dom styled-components axios prop-types
styled-icons
3b) if redux? kys and then yarn add react-redux redux redux-thunk redux-logger:
live a long life

S-ar putea să vă placă și