Add structure for adding exported Ionic application to backend server
This commit is contained in:
parent
0a97c59169
commit
55b0b1235f
8
BUILD.txt
Normal file
8
BUILD.txt
Normal file
@ -0,0 +1,8 @@
|
||||
##### FRONT END #####
|
||||
git clone git@ssh.dev.azure.com:v3/HackKu/HackKu%202020/frontend frontend
|
||||
cd frontend
|
||||
npm i
|
||||
ionic build --prod
|
||||
tar czvf target-www.tar.gz ./www
|
||||
|
||||
##### target-www.tar.gz is the artifact! #####
|
@ -61,6 +61,7 @@ const FlitterUnits = {
|
||||
* Custom units should be specified here. They will be loaded in order
|
||||
* after the core of Flitter has been initialized.
|
||||
*/
|
||||
'Ionic' : require('./app/IonicUnit'),
|
||||
// 'CustomUnit' : new CustomUnit(),
|
||||
|
||||
/*
|
||||
|
40
app/IonicUnit.js
Normal file
40
app/IonicUnit.js
Normal file
@ -0,0 +1,40 @@
|
||||
const Unit = require('libflitter/Unit')
|
||||
const cors = require('cors')
|
||||
const Express = require('express')
|
||||
const path = require('path')
|
||||
|
||||
class IonicUnit extends Unit {
|
||||
static get services() {
|
||||
return [...super.services, 'configs', 'express', 'canon', 'utility']
|
||||
}
|
||||
|
||||
constructor(...args) {
|
||||
super(...args)
|
||||
|
||||
/**
|
||||
* Fully qualified path to the root of the ionic app.
|
||||
* @type {string}
|
||||
*/
|
||||
this.directory = path.resolve(path.dirname(this.utility.root()), this.configs.get('ionic.root'))
|
||||
}
|
||||
|
||||
async go(app) {
|
||||
app.express.use(cors())
|
||||
|
||||
app.express.use('/i', [
|
||||
this.canon.get('middleware::auth:UserOnly'),
|
||||
(req, res, next) => {
|
||||
const allowed_extensions = ['.html', '.js', '.css', '.svg', '.ttf', '.jpg', '.png', '.jpeg']
|
||||
for ( const k1 in allowed_extensions ) {
|
||||
if ( req.path.endsWith(allowed_extensions[k1]) ) return next()
|
||||
}
|
||||
|
||||
return res.sendFile(path.resolve(this.directory, 'index.html'))
|
||||
},
|
||||
Express.static(this.directory),
|
||||
])
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = exports = IonicUnit
|
9
config/ionic.config.js
Normal file
9
config/ionic.config.js
Normal file
@ -0,0 +1,9 @@
|
||||
// ionic Configuration
|
||||
const ionic = {
|
||||
|
||||
// Path to the root of the ionic app from the root of the Flitter app
|
||||
root: 'www',
|
||||
|
||||
}
|
||||
|
||||
module.exports = exports = ionic
|
@ -16,6 +16,7 @@
|
||||
"author": "Garrett Mills <garrett@glmdev.tech> (https://garrettmills.dev/)",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"cors": "^2.8.5",
|
||||
"flitter-auth": "^0.18.0",
|
||||
"flitter-cli": "^0.15.2",
|
||||
"flitter-di": "^0.4.1",
|
||||
|
0
www/.gitkeep
Normal file
0
www/.gitkeep
Normal file
10
www/index.html
Normal file
10
www/index.html
Normal file
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Missing Frontend</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>You have not deployed the front-end to this application.</h1>
|
||||
</body>
|
||||
</html>
|
12
yarn.lock
12
yarn.lock
@ -648,6 +648,14 @@ core-util-is@~1.0.0:
|
||||
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
|
||||
integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=
|
||||
|
||||
cors@^2.8.5:
|
||||
version "2.8.5"
|
||||
resolved "https://registry.yarnpkg.com/cors/-/cors-2.8.5.tgz#eac11da51592dd86b9f06f6e7ac293b3df875d29"
|
||||
integrity sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==
|
||||
dependencies:
|
||||
object-assign "^4"
|
||||
vary "^1"
|
||||
|
||||
dashdash@1.7.3:
|
||||
version "1.7.3"
|
||||
resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.7.3.tgz#bf533fedaa455ed8fee11519ebfb9ad66170dcdf"
|
||||
@ -1970,7 +1978,7 @@ number-is-nan@^1.0.0:
|
||||
resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d"
|
||||
integrity sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=
|
||||
|
||||
object-assign@^4.0.1, object-assign@^4.1.0:
|
||||
object-assign@^4, object-assign@^4.0.1, object-assign@^4.1.0:
|
||||
version "4.1.1"
|
||||
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
|
||||
integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=
|
||||
@ -2889,7 +2897,7 @@ validator@^10.11.0:
|
||||
resolved "https://registry.yarnpkg.com/validator/-/validator-10.11.0.tgz#003108ea6e9a9874d31ccc9e5006856ccd76b228"
|
||||
integrity sha512-X/p3UZerAIsbBfN/IwahhYaBbY68EN/UQBWHtsbXGT5bfrH/p4NQzUCG1kF/rtKaNpnJ7jAu6NGTdSNtyNIXMw==
|
||||
|
||||
vary@~1.1.2:
|
||||
vary@^1, vary@~1.1.2:
|
||||
version "1.1.2"
|
||||
resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc"
|
||||
integrity sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=
|
||||
|
Loading…
Reference in New Issue
Block a user