This repository has been archived by the owner on Feb 17, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
1.0.0 Preparation: Initial Additions
- Loading branch information
Showing
8 changed files
with
199 additions
and
1 deletion.
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,48 @@ | ||
.eslintrc.json | ||
.DS_Store | ||
*.tgz | ||
|
||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Only dev-dependencies | ||
package-lock.json | ||
|
||
# Env information / sensitive data | ||
.env | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
sftp-config.json | ||
|
||
# Don't include dep directories. | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# NPM cache | ||
.npm | ||
|
||
# Node REPL history | ||
.node_repl_history | ||
|
||
*.tmlanguage.cache | ||
*.tmPreferences.cache | ||
*.stTheme.cache | ||
|
||
*.sublime-workspace | ||
|
||
# Sublime Package Control files | ||
Package Control.last-run | ||
Package Control.ca-list | ||
Package Control.ca-bundle | ||
Package Control.system-ca-bundle | ||
Package Control.cache/ | ||
Package Control.ca-certs/ | ||
Package Control.merged-ca-bundle | ||
Package Control.user-ca-bundle | ||
oscrypto-ca-bundle.crt | ||
bh_unicode_properties.cache |
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 @@ | ||
# NPM, Yarn, Travis ignores | ||
|
||
.eslintrc.json | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
.npm | ||
*.tgz | ||
.travis.yml | ||
|
||
# Core resource ignores | ||
|
||
docs/ | ||
media/ |
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,6 @@ | ||
language: node_js | ||
node_js: | ||
- "node" | ||
- "8" | ||
- "7" | ||
- "6" |
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,7 @@ | ||
License information: https://github.com/omnent/omnent-licenses/blob/master/licenses/OMv2-FO.txt | ||
|
||
Copyright 2017 Ethan Davis | ||
|
||
Permission is hereby granted, for free, to any person obtaining a copy of this software and associated documentation files (collectively "the Software" or "THE SOFTWARE"), to (without restriction) use, modify, copy, publish, execute, distribute, sublicense, and sell the Software and to allow people who gain access to the Software to do the same as long as this entire license and the above copyright notice are included in all copies or portions of the Software. | ||
|
||
NOTWITHSTANDING ANYTHING IN CONTRADICTION, THE AUTHORS AND COPYRIGHT HOLDERS OF THE SOFTWARE SHALL UNDER NO CIRCUMSTANCES BE HELD LIABLE FOR ANY DAMAGES, CLAIM, OR OTHER LIABILITY RELATED TO, IN CONNECTION WITH, OR CAUSED BY USE OR DISTRIBUTION OF THE SOFTWARE. THE SOFTWARE IS PROVIDED "AS-IS" AND IS NOT PROVIDED WITH WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, AND ANY WARRANTY ARISING OUR OF PRIOR COURSE OF DEALING AND USAGE OF TRADE. |
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 +1,27 @@ | ||
# vaxic | ||
<p align="center" style="text-align: center;"><img src="https://raw.githubusercontent.com/ethanent/phin/master/media/phin-textIncluded.png" width="250" alt="vaxic logo"/></p> | ||
|
||
--- | ||
|
||
> The ultra-light superpower Node web framework | ||
[Full documentation](https://ethanent.github.io/vaxic/) | [GitHub](https://github.com/ethanent/vaxic) | [NPM](https://www.npmjs.com/package/vaxic) | ||
|
||
## Install | ||
|
||
```shell | ||
npm install --save vaxic | ||
``` | ||
|
||
## Basic usage | ||
|
||
```javascript | ||
const Vaxic = require('vaxic') | ||
|
||
const app = new Vaxic() | ||
|
||
app.add('GET', '/getEndpoint', (req, res) => { | ||
res.writeHead(200) | ||
res.end('Hello.') | ||
}) | ||
``` | ||
|
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,37 @@ | ||
const path = require('path') | ||
const http = require('http') | ||
const VaxicServer = require(path.join(__dirname, 'VaxicServer.js')) | ||
|
||
class Vaxic extends VaxicServer { | ||
constructor () { | ||
super() | ||
|
||
this.internalServer = http.createServer(this.serverHandler) | ||
} | ||
|
||
add (a1, a2, a3) { | ||
const handler = { | ||
'type': 'rule', | ||
'target': { | ||
'method': (a3 ? a1 : null), | ||
'url': (a3 ? a2 : a1), | ||
}, | ||
'handler': (a3 || a2) | ||
} | ||
|
||
this.handlers.push(handler) | ||
} | ||
|
||
use (midhandler) { | ||
const handler = { | ||
'type': 'mid', | ||
'handler': midhandler | ||
} | ||
|
||
this.handlers.push(handler) | ||
} | ||
|
||
listen (port, host, cb) { | ||
this.internalServer.listen(port, host, (cb || null)) | ||
} | ||
} |
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,27 @@ | ||
class VaxicServer { | ||
constructor (handlers) { | ||
this.handlers = handlers || [] | ||
} | ||
|
||
serverHandler (req, res) { | ||
for (let i = 0; i < handlers.length; i++) { | ||
if (handlers[i].type === 'rule') { | ||
const rules = handlers[i].target | ||
|
||
if (rules.method ? (rules.method !== req.method) : false) continue | ||
|
||
if (rules.url ? (rules.url instanceof RegExp ? !rules.url.test(req.url) : (res.url.indexOf('*') === res.url.length - 1 ? res.url.indexOf(rules.url) !== 0 : res.url !== rules.url)) : false) continue | ||
|
||
handlers[i].handler(req, res) | ||
} | ||
else if (handlers[i].type === 'mid') { | ||
handlers[i].handler(req, res, () => { | ||
continue | ||
}) | ||
break | ||
} | ||
} | ||
} | ||
} | ||
|
||
module.exports = VaxicServer |
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,27 @@ | ||
{ | ||
"name": "vaxic", | ||
"version": "1.0.0", | ||
"description": "The lightweight, flexible web framework", | ||
"main": "lib/Vaxic.js", | ||
"scripts": { | ||
"test": "node test/test.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/ethanent/vaxic.git" | ||
}, | ||
"keywords": [ | ||
"web", | ||
"api", | ||
"app", | ||
"webapp", | ||
"vaxic", | ||
"http" | ||
], | ||
"author": "Ethan Davis", | ||
"license": "SEE LICENSE IN LICENSE.md", | ||
"bugs": { | ||
"url": "https://github.com/ethanent/vaxic/issues" | ||
}, | ||
"homepage": "https://github.com/ethanent/vaxic#readme" | ||
} |