-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
1,089 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
version: "3.8" | ||
|
||
services: | ||
server: | ||
build: "server/" | ||
command: "npx ts-node src/routes/github.ts" | ||
account: | ||
build: "src/account/" | ||
command: "npm run account" | ||
ports: | ||
- "4000:4000" | ||
- "8000:8000" | ||
env_file: ".env" | ||
client: | ||
build: "client/" | ||
command: "npm start" | ||
ports: | ||
- "3000:3000" | ||
env_file: ".env" | ||
# Requires server services to run before running client servers | ||
depends_on: | ||
- "server" | ||
- "5000:5000" | ||
env_file: "src/account/.env" | ||
dns: | ||
- "8.8.8.8" | ||
# client: | ||
# build: "client/" | ||
# command: "npm start" | ||
# ports: | ||
# - "3000:3000" | ||
# env_file: ".env" | ||
# # Requires server services to run before running client servers | ||
# depends_on: | ||
# - "server" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,8 @@ | ||
{ | ||
"name": "luminosityleds", | ||
"version": "0.1.0", | ||
"description": "Illuminate individual expression and creativity", | ||
"scripts": { | ||
"build": "tsc -p ./src", | ||
"account": "nodemon ./src/account/account.ts", | ||
"device": "nodemon ./src/device/device.ts", | ||
"server": "nodemon ./src/server/server.ts", | ||
"notification": "nodemon ./src/notification/notification.ts", | ||
"search": "nodemon ./src/search/search.ts" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"@types/express": "^4.17.14", | ||
"@types/node": "^18.11.9", | ||
"axios": "^1.2.6", | ||
"cors": "^2.8.5", | ||
"cors-anywhere": "^0.4.4", | ||
"express": "^4.18.2", | ||
"lodash.get": "^4.4.2", | ||
"mongoose": "^6.7.2", | ||
"nodemon": "^2.0.20", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^4.9.3" | ||
"typescript-coverage-report": "^0.7.0" | ||
}, | ||
"scripts": { | ||
"ts-coverage": "typescript-coverage-report" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
.env | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,20 @@ | ||
FROM node:16-bullseye | ||
# Base image for account microservice. This image uses amd64 as the architecture | ||
FROM amd64/node:16-bullseye | ||
|
||
# Specifies root of file structure as working directory in docker image | ||
WORKDIR / | ||
RUN npm install -g express | ||
|
||
# Copy files to root of file structure in docker image | ||
COPY account.ts / | ||
RUN ["node", "account.ts"] | ||
EXPOSE 3001 | ||
COPY config.ts / | ||
COPY IUserSchema.ts / | ||
COPY package.json / | ||
|
||
# Install all dependencies to run account microservice | ||
RUN npm install | ||
|
||
# Exposes port 5000 which is the same port specified in the express app in account.ts | ||
EXPOSE 5000 | ||
|
||
# run the command specified in the package.json to start the account microservice | ||
CMD ["npm", "run", "account"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
export interface IUserSchema { | ||
creationDate: { | ||
value: number; | ||
}; | ||
|
||
deletionDate?: { | ||
value: Number; | ||
}; | ||
|
||
lastUpdated?: { | ||
value: Number; | ||
}; | ||
|
||
email: { | ||
value: String; | ||
}; | ||
|
||
name: { | ||
value: String; | ||
}; | ||
|
||
devicesLinked?: { | ||
value: {}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Account Microservice | ||
The scope of this microservice is defined in the following [epic](https://luminosity-led.atlassian.net/browse/LL-2). | ||
|
||
## account.ts | ||
This program defines the account microservice. The microservice uses an isolated express app which exposes the following routes. | ||
|
||
### POST register | ||
This route will register a new user in the MongoDB database. | ||
|
||
## config.ts | ||
This file defines the environment variables and initalized variables with blank values for the account microservice. | ||
|
||
## IUserSchema.ts | ||
This interface defines the structure of any object that uses the interface. It corresponds to the data that will get entered into the MongoDB database. | ||
|
||
## package.json | ||
This file defines the name, version, description, scripts, and dependencies of the account microservice. | ||
|
||
### Development Scripts | ||
Uses `nodemon` which restarts the service whenever there is a change made to `account.ts`. | ||
#### How to Run | ||
```bash | ||
npm run devAccount | ||
``` | ||
|
||
### Production Scripts | ||
Uses `ts-node` which precompiles `account.ts` TypeScript code that can be run in a terminal. | ||
#### How to Run | ||
```bash | ||
npm run account | ||
``` | ||
|
||
## Dockerfile | ||
Defines how the docker images for the account microservice will be created. | ||
### How to Build Docker Image | ||
```bash | ||
docker build -t account:VERSION . | ||
``` | ||
VERSION = the version of the account microservice | ||
**Run the above command from the root of the src/account directory.** | ||
### How to Run Docker Container | ||
```bash | ||
docker run --rm -t -e USR=USR -e PSW=PSW -e CLUS=CLUS -e DB=DB -e COL=COL --network="host" --dns=8.8.8.8 account:VERSION | ||
``` | ||
**Run the above command from anywhere.** | ||
|
||
USR = username for MongoDB | ||
|
||
PSW = password for MongoDB | ||
|
||
CLUS = cluster for MongoDB | ||
|
||
DB = database for MongoDB | ||
|
||
COL = collection for MongoDB | ||
|
||
VERSION = the version of the account microservice | ||
|
||
network means tell docker container to use localhost | ||
|
||
dns means tell docker container to use google's public DNS |
Oops, something went wrong.