-
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.
Move the views directory into the resources/ directory; trim app config and create a cors and a view config from the trimmed parts; add more documentation to app config; use framework functions to unify resource and storage paths
- Loading branch information
1 parent
ec6121c
commit ea92826
Showing
39 changed files
with
201 additions
and
131 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
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 |
---|---|---|
|
@@ -17,3 +17,6 @@ storage | |
.logs | ||
.log | ||
.sqlite | ||
*.logs | ||
*.cache | ||
*.sqlite |
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 |
---|---|---|
@@ -1,39 +1,72 @@ | ||
const path = require("node:path"); | ||
const env = require("@simplicityjs/framework/env"); | ||
const string = require("@simplicityjs/framework/lib/string"); | ||
|
||
const SPLIT_REGEX = /[\s+,;|]+/; | ||
const APP_ROOT = string.convertBackSlashToForwardSlash(path.resolve(path.dirname(__dirname), "..")); | ||
const APP_SRC_DIR = `${APP_ROOT}/src`; | ||
const HTTP_REGEX = /^https?:\/\//i; | ||
|
||
let host = env("HOST"); | ||
let port = env("PORT"); | ||
let scheme = env("URL_SCHEME", "http")?.toLowerCase(); | ||
module.exports = { | ||
/* | ||
* ------------------- | ||
* Application Name | ||
* ------------------ | ||
* | ||
* This the name of your application. It is used in cases when the | ||
* framework needs to place the application's name in a notification or | ||
* any other location as required by the application or its packages. | ||
*/ | ||
name: env("APP_NAME"), | ||
|
||
if(!(/^https?(:\/\/)?/.test(scheme))) { | ||
scheme = "http://"; | ||
} | ||
/* | ||
* ------------------- | ||
* Application Port | ||
* ------------------ | ||
* | ||
* This is the port your application should run on. | ||
* It is used when the port is not specified via any other CLI means. | ||
*/ | ||
port: env("APP_PORT"), | ||
|
||
scheme = scheme.split(/:\/\//)[0] + "://"; | ||
host = (HTTP_REGEX.test(host)) ? host: `${scheme}${host}`; | ||
port = [80, 443].includes(Number(port)) ? "" : port; | ||
/* | ||
* ------------------- | ||
* Application URL | ||
* ------------------ | ||
* | ||
* This is your application's fully qualified URL. | ||
*/ | ||
url: env("APP_URL", "http://localhost"), | ||
|
||
module.exports = { | ||
name : env("NAME"), | ||
host : env("HOST"), | ||
port : env("PORT"), | ||
url : port ? `${host}:${port}` : host, | ||
urlScheme : scheme, | ||
environment : env("NODE_ENV", "production").toLowerCase(), | ||
apiVersion : env("API_VERSION"), | ||
debug : env("DEBUG"), | ||
timezone : env("TIMEZONE", "UTC").toUpperCase(), | ||
rootDir : APP_ROOT, | ||
srcDir : APP_SRC_DIR, | ||
viewsDir : `${APP_SRC_DIR}/${env("VIEWS_DIR", "views")}`, | ||
allowedHeaders : env("ALLOWED_HEADERS").split(SPLIT_REGEX).map(s => s.trim()), | ||
allowedMethods : env("ALLOWED_METHODS").split(SPLIT_REGEX).map(o => o.trim().toUpperCase()), | ||
allowedOrigins : env("ALLOWED_ORIGINS").split(SPLIT_REGEX).map(o => o.trim()), | ||
viewTemplatesEngine: env("VIEW_TEMPLATES_ENGINE"), | ||
/* | ||
* ------------------------ | ||
* Application Environment | ||
* ------------------------ | ||
* | ||
* This value determines the "environment" your application is currently | ||
* running in. It helps to determine configuration preferences | ||
* for application services. | ||
*/ | ||
environment: env("NODE_ENV", "production").toLowerCase(), | ||
|
||
debug: env("DEBUG"), | ||
|
||
/* | ||
* ------------------------ | ||
* Application Timezone | ||
* ------------------------ | ||
* | ||
* This is the default timezone for your application, which | ||
* will be used by the date and time functions. | ||
*/ | ||
timezone: env("TIMEZONE", "UTC").toUpperCase(), | ||
|
||
/* | ||
* ------------------------ | ||
* Maintenance Mode Driver | ||
* ------------------------ | ||
* | ||
* This option determines the driver used to determine and | ||
* manage Simplicity's "maintenance mode" status. The "redis" driver | ||
* makes it possible to control maintenance mode across multiple machines. | ||
* | ||
* Supported drivers include: "file" and "redis" | ||
*/ | ||
maintenance: { | ||
driver: "file", | ||
}, | ||
}; |
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
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,20 @@ | ||
const env = require("@simplicityjs/framework/env"); | ||
|
||
const REGEX = /[\s+,;|]+/; | ||
const split = str => str.split(REGEX).map(s => s.trim()); | ||
|
||
|
||
/* | ||
* -------------------------------------------------------------------------- | ||
* Cross-Origin Resource Sharing (CORS) Configuration | ||
* -------------------------------------------------------------------------- | ||
* | ||
* Here you may configure your settings for cross-origin resource sharing (CORS). | ||
* This determines what cross-origin operations may execute in web browsers. | ||
*/ | ||
module.exports = { | ||
allowedHeaders: split(env("ALLOWED_HEADERS")), | ||
allowedMethods: split(env("ALLOWED_METHODS").toUpperCase()), | ||
allowedOrigins: split(env("ALLOWED_ORIGINS")), | ||
credentials: env("USE_CREDENTIALS", false), | ||
}; |
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
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
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,29 @@ | ||
const env = require("@simplicityjs/framework/env"); | ||
const resourcePath = require("@simplicityjs/framework/resource-path"); | ||
|
||
|
||
module.exports = { | ||
/* | ||
* ------------------- | ||
* View Storage Paths | ||
* ------------------- | ||
* | ||
* Here you may specify an array of paths that should be checked | ||
* when loading view templates from disk. | ||
*/ | ||
paths: [ | ||
resourcePath("views"), | ||
], | ||
|
||
/* | ||
* ---------------------- | ||
* View Template Engine | ||
* ---------------------- | ||
* | ||
* The templating engine to use for your views. | ||
* You can specify any templating engine supported by Express. | ||
* If you specify a template engine different from pug, | ||
* make sure to install the appropriate package for the engine. | ||
*/ | ||
engine: env("VIEW_ENGINE", "pug"), | ||
}; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.