This repository contains the code for Mementos API endpoints and web app frontend.
-
Download and install Node JS. After installation, you can confirm it's installed correctly by running the commands
node --versionandnpm --versionin a terminal. -
If you are on Windows, install WSL - here are instructions for installing WSL and Ubuntu.
-
If you are on Windows, install Docker Desktop. If you are on Mac or Linux, feel free to install Docker Desktop as well for easy management of containers, but you don't have to if you're comfortable with managing containers in the terminal.
-
Download and install a code editor if you don't want to use Notepad. We recommend VSCode, but feel free to use other editors as well.
-
Clone the repository.
-
Install dependencies by executing the following command in the project directory (
install:allinstalls dependencies for both the server and the client):npm run install:all
Starting the app:
-
If you're on Windows, open Docker Desktop.
-
CD to the project directory.
-
Run the following to start dependent services:
npm run docker:up -
Run the following to start the development server:
npm run dev -
The server is now running at
localhost:3000and the client is now running atlocalhost:5173. Open a browser and go to the client URL to see the app!The server log has one status line per service it connects to, starting with
DATABASE:orEMAIL:. If MongoDB isn't running,DATABASE: could not connect to MongoDBappears after about 30 seconds and the server stops: start it (step 3), then restartnpm run dev.
Stopping the app:
-
Type
Ctrl+Cin the terminal with the server to stop the server. -
In Docker Desktop, you can press the Stop button to stop a container and persist its data. Pressing the Delete button will stop a container and delete its data. You can also delete our dependent containers with the following command:
npm run docker:down
Other helpful tools:
-
You can use MongoDB Compass to view and manipulate db data.
-
You can use Postman to send requests to the server.
Email:
New accounts must enter an emailed code before they can sign in, and "Forgot password?" emails a
reset code. No mail server is needed locally: without SMTP settings every email is printed to the
server console, so read the code from the terminal running npm run dev. The seeded users are
already verified. Weekly digests are printed there too, at 12AM UTC on each user's digest day
(see docs/ENVIRONMENT_OVERVIEW.md to trigger one).
To see the HTML version of the emails, run npm run email:preview. Sending real email over SMTP
locally is covered in docs/ENVIRONMENT_OVERVIEW.md.
If the dependencies in package.json are outdated, run the following to update them:
npm update
To fix vulnerabilities that might have appeared since the creation of this template, run the following:
npm audit fix --force
The same applies for src/client/package.json; the above commands can be run in the src/client directory.
Integration tests are written in TypeScript. To run them as TypeScript files, we use ts-jest.
-
Start dependent services:
npm run docker:up -
Run the tests:
npm run test -
Close dependent services:
npm run docker:down