This repository has been archived by the owner on Jun 23, 2023. It is now read-only.
-
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.
Initial commit. Working express 4 server, parcel builder with hot rel…
…oading. Prettier for auto formatting. Started using nav-designsystem components
- Loading branch information
0 parents
commit 87b2f2a
Showing
17 changed files
with
7,025 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"presets": ["@babel/preset-react", "@babel/preset-env"], | ||
"plugins": [["@babel/plugin-transform-runtime"]] | ||
} |
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,13 @@ | ||
.idea | ||
dist | ||
node_modules/ | ||
.cache/ | ||
frontend/src/.DS_Store | ||
frontend/fonts/ | ||
.vscode/ | ||
.env | ||
dockerbuild.sh | ||
package-lock.json | ||
|
||
.DS_Store | ||
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"printWidth": 100, | ||
"semi": false, | ||
"singleQuote": true | ||
} |
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 @@ | ||
* @navikt/aura |
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,2 @@ | ||
FROM node:13-alpine | ||
# TODO |
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,21 @@ | ||
# The MIT License | ||
|
||
Copyright 2018 NAV (Arbeids- og velferdsdirektoratet) - The Norwegian Labour and Welfare Administration | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the "Software"), | ||
to deal in the Software without restriction, including without limitation | ||
the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
and/or sell copies of the Software, and to permit persons to whom the | ||
Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included | ||
in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | ||
USE OR OTHER DEALINGS IN THE SOFTWARE. |
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,18 @@ | ||
|
||
# Nais deploy frontend | ||
|
||
TODO | ||
|
||
## Utvikling lokalt | ||
|
||
npm install -g yarn | ||
yarn run dev | ||
|
||
|
||
## Henvendelser | ||
|
||
For external contact one of: | ||
|
||
- Mats Byfuglien ([email protected]) | ||
|
||
For NAV-employees use #nais on our internal Slack |
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,56 @@ | ||
'use strict' | ||
|
||
const { host } = require('./server/config/config') | ||
const express = require('express') | ||
const favicon = require('serve-favicon') | ||
var path = require('path') | ||
const logger = require('morgan') | ||
//const prometheus = require('prom-client') | ||
const helmet = require('helmet') | ||
|
||
//prometheus.collectDefaultMetrics() | ||
|
||
const app = express() | ||
app.use( | ||
logger('dev', { | ||
skip: function(req, res) { | ||
return res.statusCode < 400 | ||
} | ||
}) | ||
) | ||
|
||
app.use(helmet()) | ||
app.use(favicon(path.join(__dirname, 'public', 'favicon.ico'))) | ||
const cors = function(req, res, next) { | ||
res.setHeader('Access-Control-Allow-Origin', host) | ||
res.setHeader('Access-Control-Allow-Credentials', 'true') | ||
res.setHeader('Access-Control-Allow-Methods', 'GET') | ||
res.setHeader( | ||
'Access-Control-Allow-Headers', | ||
'Origin, Content-Type, X-AUTHENTICATION, X-IP, Content-Type, Accept, Access-Control-Allow-Headers, Authorization, X-Requested-With' | ||
) | ||
return next() | ||
} | ||
app.use(cors) | ||
|
||
app.use(express.json()) | ||
//app.set('trust proxy', 1) | ||
|
||
// ROUTES | ||
app.use('/static', express.static(path.join(__dirname, 'dist'))) | ||
//app.use('/', router) | ||
|
||
app.get('*', (req, res) => { | ||
res.sendFile('index.html', { root: './dist' }) | ||
}) | ||
|
||
// ERROR HANDLING | ||
app.use((err, req, res, next) => { | ||
res.locals.message = err.message | ||
res.locals.error = req.app.get('env') === 'development' ? err : {} | ||
console.log('Error ' + err) | ||
res.status(err.status || 500).send(err) | ||
next() | ||
}) | ||
|
||
module.exports = app |
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,38 @@ | ||
#!/usr/bin/env node | ||
|
||
const app = require('../app') | ||
const { host, port } = require('../server/config/config') | ||
const http = require('http') | ||
var debug = require('debug')('http'), | ||
name = 'deploy-frontend' | ||
|
||
debug(`Starting up`, name) | ||
|
||
app.set('port', port) | ||
|
||
var server = http.createServer(app) | ||
server.listen(port) | ||
server.on('error', onError) | ||
server.on('listening', onListening) | ||
|
||
function onError(error) { | ||
if (error.syscall !== 'listen') { | ||
throw error | ||
} | ||
|
||
switch (error.code) { | ||
case 'EACCES': | ||
console.error(`Port ${port} requires elevated privileges`) | ||
process.exit(1) | ||
case 'EADDRINUSE': | ||
console.error(`Port ${port} is already in use`) | ||
process.exit(1) | ||
default: | ||
throw error | ||
} | ||
} | ||
|
||
function onListening() { | ||
var addr = server.address() | ||
debug(`Listening on ${host}:${addr.port}`) | ||
} |
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,12 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Nais deploy</title> | ||
<link rel="stylesheet" type="text/css" href="js/index.less" /> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script src="js/index.tsx"></script> | ||
</body> | ||
</html> |
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,11 @@ | ||
html, body { | ||
margin: 0; | ||
|
||
&, #root { | ||
height: 100%; | ||
} | ||
} | ||
|
||
* { | ||
box-sizing: border-box; | ||
} |
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,19 @@ | ||
import * as React from 'react'; | ||
import * as DOM from 'react-dom'; | ||
|
||
import { Hovedknapp } from 'nav-frontend-knapper'; | ||
import { Systemtittel } from 'nav-frontend-typografi'; | ||
|
||
import './index.less'; | ||
|
||
function Application() { | ||
return ( | ||
<div> | ||
<h1>Hei 4</h1> | ||
<Systemtittel>Test from react</Systemtittel> | ||
<Hovedknapp >Hei banan</Hovedknapp> | ||
</div> | ||
); | ||
} | ||
|
||
DOM.render(<Application />, document.getElementById('root')); |
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,60 @@ | ||
{ | ||
"name": "nais-deploy-frontend", | ||
"version": "42.0.0", | ||
"description": "Frontend for nais deploy", | ||
"scripts": { | ||
"build-watch": "parcel watch frontend/index.html --public-url /static", | ||
"start-watch": "NODE_ENV=development DEBUG=http,deploy-frontend nodemon bin/www", | ||
"dev": "concurrently --kill-others \"yarn run start-watch\" \"yarn run build-watch\"", | ||
"build": "parcel build frontend/index.html --public-url /static", | ||
"test": "echo \"TODO\" && exit 1", | ||
"start": "node ./bin/www" | ||
}, | ||
"dependencies": { | ||
"concurrently": "^5.1.0", | ||
"debug": "^4.1.1", | ||
"express": "^4.17.1", | ||
"helmet": "^3.21.3", | ||
"http": "^0.0.0", | ||
"morgan": "^1.9.1", | ||
"prop-types": "^15.7.2", | ||
"serve-favicon": "^2.5.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.0.0-0", | ||
"@babel/plugin-transform-runtime": "^7.8.3", | ||
"@babel/preset-react": "^7.8.3", | ||
"classnames": "^2.2.6", | ||
"husky": "^4.2.3", | ||
"less": "^3.11.1", | ||
"lodash.throttle": "^4.1.1", | ||
"nav-frontend-core": "^4.0.11", | ||
"nav-frontend-js-utils": "^1.0.8", | ||
"nav-frontend-knapper": "^1.0.39", | ||
"nav-frontend-knapper-style": "^0.3.34", | ||
"nav-frontend-typografi": "^2.0.17", | ||
"nav-frontend-typografi-style": "^1.0.18", | ||
"nodemon": "^2.0.2", | ||
"parcel-bundler": "^1.12.4", | ||
"prettier": "^1.19.1", | ||
"pretty-quick": "^2.0.1", | ||
"react": "^16.13.0", | ||
"react-dom": "^16.13.0", | ||
"rimraf": "^3.0.2", | ||
"typescript": "^3.8.2" | ||
}, | ||
"nodemonConfig": { | ||
"ignore": [ | ||
"dist/*", | ||
"frontend/*" | ||
] | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "pretty-quick --staged" | ||
} | ||
}, | ||
"author": "@navikt/aura", | ||
"license": "MIT", | ||
"private": true | ||
} |
Binary file not shown.
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,10 @@ | ||
exports.port = 8080 | ||
|
||
if (process.env['NODE_ENV'] === 'production') { | ||
//process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0' | ||
exports.host = process.env['HOST'] || 'localhost' | ||
//exports.sessionSecret = process.env['SESSION_SECRET'] || 'H3mligereEnnDetteBlirDetIkke!' | ||
//exports.cookieDomain = '' | ||
} else if (process.env['NODE_ENV'] === 'development') { | ||
exports.host = 'localhost' | ||
} |
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,5 @@ | ||
{ | ||
"compilerOptions": { | ||
"jsx": "react" | ||
} | ||
} |
Oops, something went wrong.