Skip to content

Commit

Permalink
feat: initial app bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
r2g committed Jun 30, 2022
0 parents commit aa4b1a2
Show file tree
Hide file tree
Showing 40 changed files with 30,397 additions and 0 deletions.
130 changes: 130 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
2 changes: 2 additions & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
api: cd api && PORT=4000 PORT_FE=3002 yarn dev
web: cd frontend && PORT=3002 yarn dev
47 changes: 47 additions & 0 deletions api/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import express from 'express';
import dotenv from 'dotenv';

dotenv.config();

const { PORT, PORT_FE, NODE_ENV } = process.env;
const port = PORT || 4000;
const port_fe = PORT_FE || port + 1;
const app = express();

// API
app.get('/health', function (req, res) {
res.json({ message: 'OK' });
});

// Serve the FE
if (NODE_ENV === 'production') {
app.use(express.static('public'));

app.get('*', function (req, res) {
res.status(404).send('404 Not Found');
});
}

// Embedding FE on Development
else {
// set the view engine to ejs
app.set('view engine', 'ejs');

// serve the root page
app.get('/', function (req, res) {
res.render('index');
});

app.get('*', function (req, res) {
if (
req.originalUrl.includes('/media') ||
req.originalUrl.includes('/static')
) {
res.redirect(`http://localhost:${port_fe}${req.originalUrl}`);
} else {
res.status(404).send('404 Not Found');
}
});
}

app.listen(port, () => console.log(`app is listening on port ${port}`));
17 changes: 17 additions & 0 deletions api/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "api",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"proxy": "http://localhost:3002",
"type": "module",
"scripts": {
"dev": "nodemon index.js"
},
"dependencies": {
"dotenv": "^16.0.1",
"ejs": "^3.1.8",
"express": "^4.18.1",
"nodemon": "^2.0.18"
}
}
16 changes: 16 additions & 0 deletions api/public/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"files": {
"main.css": "/static/css/main.073c9b0a.css",
"main.js": "/static/js/main.7097d855.js",
"static/js/787.cda612ba.chunk.js": "/static/js/787.cda612ba.chunk.js",
"static/media/logo.svg": "/static/media/logo.6ce24c58023cc2f8fd88fe9d219db6c6.svg",
"index.html": "/index.html",
"main.073c9b0a.css.map": "/static/css/main.073c9b0a.css.map",
"main.7097d855.js.map": "/static/js/main.7097d855.js.map",
"787.cda612ba.chunk.js.map": "/static/js/787.cda612ba.chunk.js.map"
},
"entrypoints": [
"static/css/main.073c9b0a.css",
"static/js/main.7097d855.js"
]
}
Binary file added api/public/favicon.ico
Binary file not shown.
1 change: 1 addition & 0 deletions api/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>React App</title><script defer="defer" src="/static/js/main.7097d855.js"></script><link href="/static/css/main.073c9b0a.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
Binary file added api/public/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added api/public/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions api/public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
3 changes: 3 additions & 0 deletions api/public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
2 changes: 2 additions & 0 deletions api/public/static/css/main.073c9b0a.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions api/public/static/css/main.073c9b0a.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions api/public/static/js/787.cda612ba.chunk.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit aa4b1a2

Please sign in to comment.