A full stack TypeScript solo project.
- Click the green
Use this templatebutton, selectCreate a new repository- Under
Ownerselect your username - Give your repository a name. Name it after your application. The name
full-stack-projectis not a good name. - (Optional) Add a description
- Leave repository as
Public - DO NOT Include all branches
- Click the green
Create repository from templatebutton
- Under
- From your newly created repo on GitHub, click the green
<> Codebutton, then copy SSH URL - Open
lfz-code, click on blue><button in bottom left oflfz-code- Select
Clone Repository in Container Volume...- If this option does not appear, open the Command Palette (cmd-shift-P on Mac or ctrl-shift-P on Windows), type "Dev Containers", and select
Clone Repository in Container Volume.... Then continue to the next step.
- If this option does not appear, open the Command Palette (cmd-shift-P on Mac or ctrl-shift-P on Windows), type "Dev Containers", and select
- Paste SSH URL for your repo, click
Clone git repository from URL
- Select
- Install all dependencies with
npm install.
If your project will be using a database, create it now.
- Start PostgreSQL
sudo service postgresql start
- Create database (replace
name-of-databasewith a name of your choosing, such as the name of your app)createdb name-of-database
- In the
server/.envfile, in theDATABASE_URLvalue, replacechangeMewith the name of your database, from the last step - While you are editing
server/.env, also change the value ofTOKEN_SECRETto a custom value, without spaces. - Make the same changes to
server/.env.example. (Don't worry about theTOKEN_SECRET, this value is used only during development. When you deploy, you will provide a different value using the AWS Secrets Manager.)
If your project will not be using a database, edit package.json to remove the dev:db script.
- Start all the development servers with the
"dev"script:npm run dev
- Later, when you wish to stop the development servers, type
Ctrl-Cin the terminal where the servers are running.
- A React app has already been created for you.
- Take a minute to look over the code in
client/src/App.tsxto get an idea of what it is doing. - Go to the app in your browser. You should see the message from the server below the React logo, and in the browser console.

- If you see the message from the server in your browser you are good to go, your client and server are communicating.
-
In your browser navigate to the site you used for your database design.
-
Export your database as PostgreSQL, this should generate the SQL code for creating your database tables.
- Reach out to an instructor if you have any issues with this step
-
Copy the generated SQL code and paste it into
database/schema.sqlbelow the preexisting sql code in the file. The end result should look something like: (You will likely have more tables)set client_min_messages to warning; -- DANGER: this is NOT how to do it in the real world. -- `drop schema` INSTANTLY ERASES EVERYTHING. drop schema "public" cascade; create schema "public"; create table "todos" ( "todoId" serial PRIMARY KEY, "task" text not null, "isCompleted" boolean not null, "createdAt" timestamptz not null DEFAULT now(), "updatedAt" timestamptz not null DEFAULT now() );
-
In a separate terminal, run
npm run db:importto create your tables -
Use
pgweborpsqlto verify your tables were created successfully (see LFZ Database Guide for tips). Your database and tables should be listed; if not, stop here and reach out to an instructor for help -
At this point your database is setup and you are good to start using it. However there is no data in your database, which isn't necessarily a bad thing, but if you want some starting data in your database you need to add insert statements into the
database/data.sqlfile. You can add whatever starting data you need/want. Here is an example:insert into "todos" ("task", "isCompleted") values ('Learn to code', false), ('Build projects', false), ('Get a job', false);
-
After any changes to
database/schema.sqlordatabase/data.sqlre-run thenpm run db:importcommand to update your database. Usepgweborpsqlto verify your changes were successfully applied.
Once your template is set up and functional, deploy it. This will get all the deployment issues ironed out early. During development, you should re-deploy frequently to make sure that your code works properly in your production environment. Deployment instructions can be found HERE
Below is an explanation of all included npm commands in the root package.json. Several are only used for deployment purposes and should not be necessary for development.
start- The
startscript starts the Node server inproductionmode, without any file watchers.
- The
build- The
buildscript executesnpm run buildin the context of theclientfolder. This builds your React app for production. This is used during deployment, and not commonly needed during development.
- The
db:import- The
db:importscript executesdatabase/import.sh, which executes thedatabase/schema.sqlanddatabase/data.sqlfiles to build and populate your database.
- The
dev- Starts all the development servers.
lint- Runs ESLint against all the client and server code.
psql- When used on the EC2 instance, runs
psqlattached to the project database. Helpful for debugging issues with the database.
- When used on the EC2 instance, runs
tsc- Runs the TypeScript compiler against all the client and server code.
- Not directly used by developer
install:*
- These scripts install dependencies in the
clientandserverfolders, and copy.env.exampleto.envif it doesn't already exist.
dev:*
- These scripts start the individual development servers.
lint:*
- These scripts run lint in the client and server directories.
tsc:*
- These scripts run tsc in the client and server directories.
postinstall- The
postinstallscript is automatically run when you runnpm install. It is executed after the dependencies are installed. Specifically for this project thepostinstallscript is used to install theclientandserverdependencies.
- The
prepare- The
preparescript is similar topostinstall— it is executed beforeinstall. Specifically for this project it is used to installhusky.
- The
deploy- The
deployscript is used to deploy the project by pushing themainbranch to thepubbranch, which triggers the GitHub Action that deploys the project.
- The