Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 2b57330

Browse files
authored
Merge pull request #181 from topcoder-platform/dev
Earn Restructure PR
2 parents 4e660b9 + 8015c0b commit 2b57330

File tree

231 files changed

+454
-17298
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

231 files changed

+454
-17298
lines changed

README.md

+8-27
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,30 @@ This is a [single-spa](https://single-spa.js.org/) example React microapp.
1616
| Command | Description |
1717
| --------------------- | ----------------------------------------------------------------- |
1818
| `npm start` | Run server which serves production ready build from `dist` folder |
19-
| `npm run dev` | Run app in the development mode |
20-
| `npm run dev-https` | Run app in the development mode using HTTPS protocol |
21-
| `npm run build` | Build app for production and puts files to the `dist` folder |
19+
| `npm run dev` | Run app in the `development` mode and `dev` config |
20+
| `npm run dev-https` | Run app in the `development` mode and `dev` config using HTTPS protocol |
21+
| `npm run local` | Run app in the `development` mode and `local-dev` config |
22+
| `npm run prod` | Run app in the `development` mode and `prod` config |
23+
| `npm run build` | Build app for production and puts files to the `dist` folder, default to `development` mode and `local-dev` config |
2224
| `npm run analyze` | Analyze dependencies sizes and opens report in the browser |
2325
| `npm run lint` | Check code for lint errors |
2426
| `npm run format` | Format code using prettier |
2527
| `npm run test` | Run unit tests |
2628
| `npm run watch-tests` | Watch for file changes and run unit tests on changes |
2729
| `npm run coverage` | Generate test code coverage report |
28-
| `npm run mock-api` | Start the mock api which mocks Recruit api |
2930

3031
## Local Deployment
3132

3233
Inside the project folder run:
33-
34-
- `export APPMODE="development"; export APPENV="local";` - to load APPMODE & APPENV
3534
- `nvm use 10.22.1;` - to use npm version: 10.22.1
3635
- `npm i` - install dependencies
37-
- `npm run dev` - run app in development mode
38-
- As this app can be loaded only inside a frame single-spa, you have to run a `micro-frontends-frame` frame app and configure it to use the URL `http://localhost:8008/topcoder-micro-frontends-earn-app.js`.
36+
- `npm run local` - run app in `development` mode and `local-dev` config
37+
- As this app can be loaded only inside a frame single-spa, you have to run a `micro-frontends-frame` frame app and configure it to use the URL `http://localhost:8008/earn-app/topcoder-micro-frontends-earn-app.js`.
3938

4039
## Deployment to Production
4140

4241
- `npm i` - install dependencies
43-
- `npm build` - build code to `dist/` folder
42+
- `APPMODE=production APPENV=prod npm run build` - build code to `dist/` folder
4443
- Now you can host `dist/` folder using any static server. For example, you may run a simple `Express` server by running `npm start`.
4544

4645
### Deploying to Heroku
@@ -58,21 +57,3 @@ Make sure you have [Heroky CLI](https://devcenter.heroku.com/articles/heroku-cli
5857
- `git push heroku master` - push changes to Heroku and trigger deploying
5958

6059
- Now you have to configure frame app to use the URL provided by Heroku like `https://<APP-NAME>.herokuapp.com/earn-app/topcoder-micro-frontends-earn-app.js` to load this microapp.
61-
62-
### Aggregator API
63-
64-
Please refer to [Swagger Doc](./src/api/docs/swagger.yaml) for Aggregator API endpoints
65-
66-
#### Aggregator API Configuration
67-
68-
In the `micro-frontends-earn-app` root directory create `.env` file with the next environment variables.
69-
70-
```bash
71-
# Auth0 config
72-
AUTH_SECRET=
73-
AUTH0_URL=
74-
AUTH0_AUDIENCE=
75-
AUTH0_CLIENT_ID=
76-
AUTH0_CLIENT_SECRET=
77-
```
78-
Once the earn app is started, the aggregator api will work as well

babel.config.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
let cssLocalIdent;
2-
if (process.env.APPMODE == 'development') {
3-
cssLocalIdent = 'earn_[path][name]___[local]___[hash:base64:6]';
4-
} else {
2+
if (process.env.APPMODE === 'production') {
53
cssLocalIdent = '[hash:base64:6]';
4+
} else {
5+
cssLocalIdent = 'earn_[path][name]___[local]___[hash:base64:6]';
66
}
77

88
const config = {

config/default.js

+5-49
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,8 @@
11
require("dotenv").config();
2+
23
module.exports = {
3-
GUIKIT: {
4-
DEBOUNCE_ON_CHANGE_TIME: 150,
5-
},
6-
API: {
7-
V5: "https://api.topcoder-dev.com/v5",
8-
V3: "https://api.topcoder-dev.com/v3",
9-
},
10-
URL: {
11-
BASE: "https://www.topcoder-dev.com",
12-
COMMUNITY_APP: "https://community-app.topcoder-dev.com",
13-
PLATFORM_WEBSITE_URL: "https://platform.topcoder-dev.com",
14-
},
15-
RECRUIT_API: "https://www.topcoder-dev.com",
16-
// the server api base path
17-
API_BASE_PATH: process.env.API_BASE_PATH || "/earn-app/api/my-gigs",
18-
// the log level, default is 'debug'
19-
LOG_LEVEL: process.env.LOG_LEVEL || "debug",
20-
// The authorization secret used during token verification.
21-
AUTH_SECRET:
22-
process.env.AUTH_SECRET,
23-
// The valid issuer of tokens, a json array contains valid issuer.
24-
VALID_ISSUERS:
25-
process.env.VALID_ISSUERS,
26-
// Auth0 URL, used to get TC M2M token
27-
AUTH0_URL:
28-
process.env.AUTH0_URL,
29-
// Auth0 audience, used to get TC M2M token
30-
AUTH0_AUDIENCE: process.env.AUTH0_AUDIENCE,
31-
// Auth0 client id, used to get TC M2M token
32-
AUTH0_CLIENT_ID:
33-
process.env.AUTH0_CLIENT_ID,
34-
// Auth0 client secret, used to get TC M2M token
35-
AUTH0_CLIENT_SECRET:
36-
process.env.AUTH0_CLIENT_SECRET,
37-
// Proxy Auth0 URL, used to get TC M2M token
38-
AUTH0_PROXY_SERVER_URL: process.env.AUTH0_PROXY_SERVER_URL,
39-
m2m: {
40-
M2M_AUDIT_USER_ID:
41-
process.env.M2M_AUDIT_USER_ID ,
42-
M2M_AUDIT_HANDLE: process.env.M2M_AUDIT_HANDLE,
43-
},
44-
MOCK_API_PORT: process.env.MOCK_API_PORT || 4000,
45-
ALLOWED_FILE_TYPES: process.env.ALLOWED_FILE_TYPES || [
46-
"pdf",
47-
"doc",
48-
"docx",
49-
"txt",
50-
],
51-
MAX_ALLOWED_FILE_SIZE_MB: process.env.MAX_ALLOWED_FILE_SIZE_MB || 10,
4+
MFE_CONFIG: {
5+
'@topcoder/micro-frontends-challenges-app': 'https://platform.topcoder-dev.com/challenges-app/topcoder-micro-frontends-challenges-app.js',
6+
'@topcoder/micro-frontends-gigs-app': 'https://platform.topcoder-dev.com/gigs-app/topcoder-micro-frontends-gigs-app.js',
7+
}
528
};

config/dev.js

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module.exports = {
2+
};

config/development.js

-15
This file was deleted.

config/local-dev.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
MFE_CONFIG: {
3+
'@topcoder/micro-frontends-challenges-app': 'http://localhost:8009/challenges-app/topcoder-micro-frontends-challenges-app.js',
4+
'@topcoder/micro-frontends-gigs-app': 'http://localhost:8010/gigs-app/topcoder-micro-frontends-gigs-app.js',
5+
}
6+
};

config/prod.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
MFE_CONFIG: {
3+
'@topcoder/micro-frontends-challenges-app': 'http://platform.topcoder.com/challenges-app/topcoder-micro-frontends-challenges-app.js',
4+
'@topcoder/micro-frontends-gigs-app': 'http://platform.topcoder.com/gigs-app/topcoder-micro-frontends-gigs-app.js',
5+
}
6+
};

config/production.js

-15
This file was deleted.

docker/Dockerfile

-20
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,9 @@ FROM node:10.22.1
33

44
ARG APPMODE
55
ARG APPENV
6-
ARG RECRUIT_API
7-
ARG AUTH_SECRET
8-
ARG VALID_ISSUERS
9-
ARG AUTH0_URL
10-
ARG AUTH0_AUDIENCE
11-
ARG AUTH0_CLIENT_ID
12-
ARG AUTH0_CLIENT_SECRET
13-
ARG AUTH0_PROXY_SERVER_URL
14-
ARG M2M_AUDIT_USER_ID
15-
ARG M2M_AUDIT_HANDLE
166

177
ENV APPMODE=$APPMODE
188
ENV APPENV=$APPENV
19-
ENV RECRUIT_API=$RECRUIT_API
20-
ENV AUTH_SECRET=$AUTH_SECRET
21-
ENV VALID_ISSUERS=$VALID_ISSUERS
22-
ENV AUTH0_URL=$AUTH0_URL
23-
ENV AUTH0_AUDIENCE=$AUTH0_AUDIENCE
24-
ENV AUTH0_CLIENT_ID=$AUTH0_CLIENT_ID
25-
ENV AUTH0_CLIENT_SECRET=$AUTH0_CLIENT_SECRET
26-
ENV AUTH0_PROXY_SERVER_URL=$AUTH0_PROXY_SERVER_URL
27-
ENV M2M_AUDIT_USER_ID=$M2M_AUDIT_USER_ID
28-
ENV M2M_AUDIT_HANDLE=$M2M_AUDIT_HANDLE
299

3010
# Copy the current directory into the Docker image
3111
COPY . /micro-frontends-earn-app

0 commit comments

Comments
 (0)