This repository contains the Node/Express webserver and DynamoDB API routes/controllers for the pennant-notebook project.
Ensure you have a .env
file set up in your project root. You can use the .env.example
file in the repository as a template. Copy it and rename to .env
, then fill in the necessary environment variables.
- Clone the repository:
git clone https://github.com/pennant-notebook/server.git
- Navigate to the project directory:
cd server
- Install the necessary npm packages:
npm install
For development purposes, you can run the server using the following command which will enable hot-reloading:
npm run dev
Before deploying the server in a production environment, build the project using the following command:
npm run build
After building the project, start the server using:
npm start
This will start the server using the built files in the dist directory.
Field | Type |
---|---|
username |
string |
hashedPassword |
string |
provider |
string |
userID |
UUID string |
- Partition key:
username
- Provider options:
google
,github
,username
, ornull
(used only in auth flow – seeauth.js
for more details)
Field | Type |
---|---|
username |
string |
title |
string |
docID |
UUID string |
- Partition key:
docID
(String) - Sort key:
username
(String)
- Endpoint:
GET /api/user/:username
- Description: Fetches a user from the
notebookusers
table.
- Endpoint:
POST /api/user/:username
- Description: Creates a new user in the
notebookusers
table.
- Endpoint:
GET /api/user/:username/notebooks
- Description: Fetches all notebooks for a given user from the
notebooks
table.
- Endpoint:
GET /api/doc/:docID/:username
- Description: Fetches a notebook with a given
docID
andusername
from thenotebooks
table.
- Endpoint:
POST /api/doc/:username
- Description: Creates a new notebook for a given
username
in thenotebooks
table.
- Endpoint:
PUT /api/doc/:docID/:username
- Description: Edits the title for a notebook for a given
docID
in thenotebooks
table. - Request Body: Expects a JSON object containing the new title as a
title
property (e.g.,{ "title": "New Title Here" }
).