Skip to content

Commit

Permalink
Merge pull request #5 from HyperTHD/chris-help
Browse files Browse the repository at this point in the history
Updated readme, docker-compose files, and user related files
  • Loading branch information
chrispinkney committed Mar 18, 2021
2 parents b91b240 + dbe714b commit e8850f5
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 244 deletions.
26 changes: 16 additions & 10 deletions config/env.production
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,22 @@ MOCK_REDIS=

# Firebase's private api key. Used to authenticate telescope with firebase
# See https://firebase.google.com/docs/admin/setup#initialize-sdk to obtain the key
TYPE=
PROJECT_ID=
PRIVATE_KEY_ID=
PRIVATE_KEY=
CLIENT_EMAIL=
CLIENT_ID=
AUTH_URI=
TOKEN_URI=
AUTH_PROVIDER_X509_CERT_URL=
CLIENT_X509_CERT_URL=
FIREBASE_TYPE=
FIREBASE_PROJECT_ID=
FIREBASE_PRIVATE_KEY_ID=
FIREBASE_PRIVATE_KEY=
FIREBASE_CLIENT_EMAIL=
FIREBASE_CLIENT_ID=
FIREBASE_AUTH_URI=
FIREBASE_TOKEN_URI=
FIREBASE_AUTH_PROVIDER_X509_CERT_URL=
FIREBASE_CLIENT_X509_CERT_URL=

# User Service Port (default is 6666)
USER_PORT=6666

# User Service URL
USER_URL=http://api.telescope.cdot.systems/v1/user


################################################################################
Expand Down
27 changes: 16 additions & 11 deletions config/env.staging
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,22 @@ MOCK_REDIS=

# Firebase's private api key. Used to authenticate telescope with firebase
# See https://firebase.google.com/docs/admin/setup#initialize-sdk to obtain the key
TYPE=
PROJECT_ID=
PRIVATE_KEY_ID=
PRIVATE_KEY=
CLIENT_EMAIL=
CLIENT_ID=
AUTH_URI=
TOKEN_URI=
AUTH_PROVIDER_X509_CERT_URL=
CLIENT_X509_CERT_URL=

FIREBASE_TYPE=
FIREBASE_PROJECT_ID=
FIREBASE_PRIVATE_KEY_ID=
FIREBASE_PRIVATE_KEY=
FIREBASE_CLIENT_EMAIL=
FIREBASE_CLIENT_ID=
FIREBASE_AUTH_URI=
FIREBASE_TOKEN_URI=
FIREBASE_AUTH_PROVIDER_X509_CERT_URL=
FIREBASE_CLIENT_X509_CERT_URL=

# User Service Port (Default is 6666)
USER_PORT=6666

# User Service URL
USER_URL=https://dev.api.telescope.cdot.systems/v1/user

################################################################################
# Feed Discovery Service
Expand Down
24 changes: 24 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,30 @@ services:
- 'traefik.http.middlewares.strip_feed_discovery_prefix.stripprefix.forceSlash=true'
- 'traefik.http.routers.feed-discovery.middlewares=strip_feed_discovery_prefix'

# user service
user:
container_name: 'user'
build:
context: ../src/api/user
dockerfile: Dockerfile
environment:
- USER_PORT
ports:
- ${USER_PORT}
depends_on:
- traefik
labels:
# Enable Traefik
- 'traefik.enable=true'
# Traefik routing for the user service at /v1/user
- 'traefik.http.routers.user.rule=PathPrefix(`/${API_VERSION}/user`)'
# Specify the user service port
- 'traefik.http.services.user.loadbalancer.server.port=${USER_PORT}'
# Add middleware to this route to strip the /v1/user prefix
- 'traefik.http.middlewares.strip_user_prefix.stripprefix.prefixes=/${API_VERSION}/user'
- 'traefik.http.middlewares.strip_user_prefix.stripprefix.forceSlash=true'
- 'traefik.http.routers.user.middlewares=strip_user_prefix'

##############################################################################
# Third-Party Dependencies and Support Services
##############################################################################
Expand Down
10 changes: 10 additions & 0 deletions docker/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ services:
# - ELASTICSEARCH_HOSTS=http://elasticsearch:9200
# - ELASTIC_APM_SERVICE_NAME=posts
# - ELASTIC_APM_SERVER_URL=http://apm:8200
# user service
user:
restart: unless-stopped
environment:
- NODE_ENV=production
- USER_PORT
# TODO
# - ELASTICSEARCH_HOSTS=http://elasticsearch:9200
# - ELASTIC_APM_SERVICE_NAME=user
# - ELASTIC_APM_SERVER_URL=http://apm:8200

##############################################################################
# Third-Party Dependencies and Support Services
Expand Down
108 changes: 0 additions & 108 deletions src/api/docker-compose.yml

This file was deleted.

92 changes: 0 additions & 92 deletions src/api/env.development

This file was deleted.

26 changes: 13 additions & 13 deletions src/api/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,22 @@ npm run services:stop

## API Lookup Table

| API | Docker Tag | URL | Description |
| ----- | ------------------- | ------------------------- | ------------------------------------------------- |
| posts | telescope_posts_svc | http://localhost/v1/posts | Provides access to cached user posts |
| image | telescope_img_svc | http://localhost/v1/image | Provides a dynamic image processing service |
| auth | telescope_auth_svc | http://localhost/v1/auth | Provides authentication and authorization service |
| API | Docker Tag | URL | Description |
| ----- | ------------------- | --------------------------- | ------------------------------------------------- |
| posts | telescope_posts_svc | <http://localhost/v1/posts> | Provides access to cached user posts |
| image | telescope_img_svc | <http://localhost/v1/image> | Provides a dynamic image processing service |
| auth | telescope_auth_svc | <http://localhost/v1/auth> | Provides authentication and authorization service |

## Support Services Lookup Table (development only)

| API | URL | Description |
| ------------------ | -------------------------------- | ------------------------------------------------------------------------- |
| Traefik Dashboard | http://localhost:8080 | [Traefik Dashboard](https://doc.traefik.io/traefik/operations/dashboard/) |
| Redis | redis://localhost:6379 | Redis server |
| Elasticsearch | http://localhost:9200 | Elasticserach |
| Firebase UI | http://localhost:4000 | UI Dashboard to Firebase Emulator |
| Firebase Firestore | http://localhost:8088 | Firestore Emulator Service |
| Login | http://localhost:8081/simplesaml | SAML SSO Identity Provider |
| API | URL | Description |
| ------------------ | ---------------------------------- | ------------------------------------------------------------------------- |
| Traefik Dashboard | <http://localhost:8080> | [Traefik Dashboard](https://doc.traefik.io/traefik/operations/dashboard/) |
| Redis | redis://localhost:6379 | Redis server |
| Elasticsearch | <http://localhost:9200> | Elasticserach |
| Firebase UI | <http://localhost:4000> | UI Dashboard to Firebase Emulator |
| Firebase Firestore | <http://localhost:8088> | Firestore Emulator Service |
| Login | <http://localhost:8081/simplesaml> | SAML SSO Identity Provider |

## References

Expand Down
12 changes: 6 additions & 6 deletions src/api/user/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ npm run jest:e2e (or npm run jest:e2e src\api\user\test\e2e)
npm run dev
```

By default the server is running on http://localhost:6666/.
By default the server is running on <http://localhost:6666/>.

### Examples

\- `GET /user/:id` - returns 200 with the user specified by the id, or 404 if a user does not exist.
\- `GET /:id` - returns 200 with the user specified by the id, or 404 if a user does not exist.

\- `GET /users` - returns 200 with all Telescope users in an array, or 404 if the `users` collection is empty.
\- `GET /` - returns 200 with all Telescope users in an array, or 404 if the `users` collection is empty.

\- `POST /user` - returns 201 if a Telescope user was successfully validated and added to the db, or 400 if the user already exists. (_An example of the JSON data to send as the POST body can be found in `api/user/test/user.test.js`_)
\- `POST /` - returns 201 if a Telescope user was successfully validated and added to the db, or 400 if the user already exists. (_An example of the JSON data to send as the POST body can be found in `api/user/test/user.test.js`_)

\- `PUT /user/:id` - returns 200 if a Telescope user's data was successfully updated, or 400 if the user could not be found in the db. (_An example of the JSON data to send as the POST body can be found in `api/user/test/user.test.js`_)
\- `PUT /:id` - returns 200 if a Telescope user's data was successfully updated, or 400 if the user could not be found in the db. (_An example of the JSON data to send as the POST body can be found in `api/user/test/user.test.js`_)

\- `DELETE /user/:id` - returns 200 when the user is deleted, or 404 if a user to delete could not be found.
\- `DELETE /:id` - returns 200 when the user is deleted, or 404 if a user to delete could not be found.

## Docker (section currently incomplete)

Expand Down
4 changes: 1 addition & 3 deletions src/api/user/src/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ class User {
this.id = data.id;
this.firstName = data.firstName;
this.lastName = data.lastName;
this.displayName = !data.displayName
? `${this.firstName}${' '}${this.lastName}`
: data.displayName;
this.displayName = data.displayName || `${this.firstName}${' '}${this.lastName}`;
this.isAdmin = data.isAdmin;
this.isFlagged = data.isFlagged;
this.feeds = data.feeds;
Expand Down
2 changes: 1 addition & 1 deletion src/api/user/src/routes/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ router.put('/:id', validateUser(), async (req, res, next) => {

if (!doc.exists) {
logger.debug(`User data (id: ${doc.id}) was requested by ${req.ip} but could not be found.`);
res.status(400).json({
res.status(404).json({
msg: `User with id ${doc.id} was requested to be updated, but does not exist in the db.`,
});
} else {
Expand Down

0 comments on commit e8850f5

Please sign in to comment.