Skip to content
This repository has been archived by the owner on Feb 17, 2024. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
1.0.0 Preparation: Initial Additions
  • Loading branch information
ethanent committed Oct 1, 2017
1 parent f5fa50e commit b9ff21d
Show file tree
Hide file tree
Showing 8 changed files with 199 additions and 1 deletion.
48 changes: 48 additions & 0 deletions .gitignore
@@ -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
20 changes: 20 additions & 0 deletions .npmignore
@@ -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/
6 changes: 6 additions & 0 deletions .travis.yml
@@ -0,0 +1,6 @@
language: node_js
node_js:
- "node"
- "8"
- "7"
- "6"
7 changes: 7 additions & 0 deletions LICENSE.md
@@ -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.
28 changes: 27 additions & 1 deletion README.md
@@ -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.')
})
```

37 changes: 37 additions & 0 deletions lib/Vaxic.js
@@ -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))
}
}
27 changes: 27 additions & 0 deletions lib/VaxicServer.js
@@ -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
27 changes: 27 additions & 0 deletions package.json
@@ -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"
}

0 comments on commit b9ff21d

Please sign in to comment.