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

Commit 1b1c97b

Browse files
committed
Baseline for the Navbar
1 parent 8bbe824 commit 1b1c97b

Some content is hidden

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

51 files changed

+27435
-1
lines changed

.eslintrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": ["react-important-stuff", "plugin:prettier/recommended"],
3+
"parser": "babel-eslint"
4+
}

.gitignore

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
9+
# Diagnostic reports (https://nodejs.org/api/report.html)
10+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11+
12+
# Runtime data
13+
pids
14+
*.pid
15+
*.seed
16+
*.pid.lock
17+
18+
# Directory for instrumented libs generated by jscoverage/JSCover
19+
lib-cov
20+
21+
# Coverage directory used by tools like istanbul
22+
coverage
23+
*.lcov
24+
25+
# nyc test coverage
26+
.nyc_output
27+
28+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29+
.grunt
30+
31+
# Bower dependency directory (https://bower.io/)
32+
bower_components
33+
34+
# node-waf configuration
35+
.lock-wscript
36+
37+
# Compiled binary addons (https://nodejs.org/api/addons.html)
38+
build/Release
39+
40+
# Dependency directories
41+
node_modules/
42+
jspm_packages/
43+
44+
# TypeScript v1 declaration files
45+
typings/
46+
47+
# TypeScript cache
48+
*.tsbuildinfo
49+
50+
# Optional npm cache directory
51+
.npm
52+
53+
# Optional eslint cache
54+
.eslintcache
55+
56+
# Microbundle cache
57+
.rpt2_cache/
58+
.rts2_cache_cjs/
59+
.rts2_cache_es/
60+
.rts2_cache_umd/
61+
62+
# Optional REPL history
63+
.node_repl_history
64+
65+
# Output of 'npm pack'
66+
*.tgz
67+
68+
# Yarn Integrity file
69+
.yarn-integrity
70+
71+
# dotenv environment variables file
72+
.env
73+
.env.test
74+
75+
# parcel-bundler cache (https://parceljs.org/)
76+
.cache
77+
78+
# Next.js build output
79+
.next
80+
81+
# Nuxt.js build / generate output
82+
.nuxt
83+
dist
84+
85+
# Gatsby files
86+
.cache/
87+
# Comment in the public line in if your project uses Gatsby and *not* Next.js
88+
# https://nextjs.org/blog/next-9-1#public-directory-support
89+
# public
90+
91+
# vuepress build output
92+
.vuepress/dist
93+
94+
# Serverless directories
95+
.serverless/
96+
97+
# FuseBox cache
98+
.fusebox/
99+
100+
# DynamoDB Local files
101+
.dynamodb/
102+
103+
# TernJS port file
104+
.tern-port

.prettierignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.gitignore
2+
.prettierignore
3+
yarn.lock
4+
yarn-error.log
5+
package-lock.json
6+
dist
7+
*.svg
8+
.DS_Store
9+
coverage

README.md

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,57 @@
1-
# micro-frontends-navbar-app
1+
# Topcoder Navbar Microapp
2+
3+
This is a [single-spa](https://single-spa.js.org/) microapp which shows the main top bar for Topcoder websites and handles user authorization.
4+
5+
> NOTE. This application have been configured to be run as child app of a single-spa application. So while this app can be deployed and run independently, we would need some frame [single-spa](https://single-spa.js.org/) which would load it. While technically we can achieve running this app as standalone app it's strongly not recommended by the author of the `single-spa` approch, see this [GitHub Issue](https://github.com/single-spa/single-spa/issues/640) for details.
6+
7+
## Requirements
8+
9+
- node - v10.22.1
10+
- npm - v6.14.6
11+
12+
## Config
13+
14+
There are 2 config file for production and development environment in the `config` folder.
15+
Set environment variable `NODE_ENV=development` to use development config, or `NODE_ENV=production` to use production config.
16+
17+
## NPM Commands
18+
19+
| Command | Description |
20+
| --------------------- | ----------------------------------------------------------------- |
21+
| `npm start` | Run server which serves production ready build from `dist` folder |
22+
| `npm run dev` | Run app in the development mode |
23+
| `npm run dev-https` | Run app in the development mode using HTTPS protocol |
24+
| `npm run build` | Build app for production and puts files to the `dist` folder |
25+
| `npm run analyze` | Analyze dependencies sizes and opens report in the browser |
26+
| `npm run lint` | Check code for lint errors |
27+
| `npm run format` | Format code using prettier |
28+
| `npm run test` | Run unit tests |
29+
| `npm run watch-tests` | Watch for file changes and run unit tests on changes |
30+
| `npm run coverage` | Generate test code coverage report |
31+
32+
## Local Deployment
33+
34+
Inside the project folder run:
35+
36+
- `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:8080/topcoder-micro-frontends-navbar-app.js`.
39+
40+
## Deployment to Production
41+
42+
- `npm i` - install dependencies
43+
- `npm build` - build code to `dist/` folder
44+
- Now you can host `dist/` folder using any static server. For example, you may run a simple `Express` server by running `npm start`.
45+
46+
### Deploying to Heroku
47+
48+
Make sure you have [Heroky CLI](https://devcenter.heroku.com/articles/heroku-cli) installed and you have a Heroku account. And then inside the project folder run the next commands:
49+
50+
- If there is not Git repository inited yet, create a repo and commit all the files:
51+
- `git init`
52+
- `git add .`
53+
- `git commit -m'inital commit'`
54+
- `heroku apps:create` - create Heroku app
55+
- `git push heroku master` - push changes to Heroku and trigger deploying
56+
- Now you have to configure frame app to use the URL provided by Heroku like `https://<APP-NAME>.herokuapp.com/topcoder-micro-frontends-navbar-app.js` to load this microapp.
57+
- NOTE: Authorization would not work because only predefined list of domain allowed by `accounts-app`.

babel.config.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"presets": ["@babel/preset-env", "@babel/preset-react"],
3+
"plugins": [
4+
[
5+
"@babel/plugin-transform-runtime",
6+
{
7+
"useESModules": true,
8+
"regenerator": false
9+
}
10+
]
11+
],
12+
"env": {
13+
"test": {
14+
"presets": [
15+
[
16+
"@babel/preset-env",
17+
{
18+
"targets": "current node"
19+
}
20+
]
21+
]
22+
}
23+
}
24+
}

config/development.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = {
2+
URL: {
3+
ACCOUNTS_APP_CONNECTOR: "https://accounts.topcoder-dev.com/connector.html",
4+
AUTH: "https://accounts.topcoder-dev.com",
5+
},
6+
API: {
7+
V3: "https://api.topcoder-dev.com/v3",
8+
},
9+
REAUTH_TIME: 55,
10+
};

config/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* global process */
2+
3+
module.exports = (() => {
4+
const env = process.env.NODE_ENV || "development";
5+
6+
// for security reason don't let to require any arbitrary file defined in process.env
7+
if (["production", "development"].indexOf(env) < 0) {
8+
return require("./development");
9+
}
10+
11+
return require("./" + env);
12+
})();

config/production.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = {
2+
URL: {
3+
ACCOUNTS_APP_CONNECTOR: "https://accounts.topcoder.com/connector.html",
4+
AUTH: "https://accounts.topcoder.com",
5+
},
6+
API: {
7+
V3: "https://api.topcoder.com/v3",
8+
},
9+
REAUTH_TIME: 55,
10+
};

jest.config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
rootDir: "src",
3+
transform: {
4+
"^.+\\.(j|t)sx?$": "babel-jest",
5+
},
6+
transformIgnorePatterns: ["node_modules/?!(tc-accounts)"],
7+
moduleNameMapper: {
8+
"\\.css$": "identity-obj-proxy",
9+
"\\.svg$": "<rootDir>/__mocks__/fileMock.js",
10+
},
11+
setupFilesAfterEnv: [
12+
"../node_modules/@testing-library/jest-dom/dist/index.js",
13+
],
14+
};

0 commit comments

Comments
 (0)