https://github.com/palerdot/dexpressjs
Simple nodejs routing framework created for learning purpose.
https://github.com/palerdot/dexpressjs
Last synced: about 1 year ago
JSON representation
Simple nodejs routing framework created for learning purpose.
- Host: GitHub
- URL: https://github.com/palerdot/dexpressjs
- Owner: palerdot
- Created: 2015-04-12T13:28:19.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-04-12T13:32:28.000Z (about 11 years ago)
- Last Synced: 2025-02-11T14:51:29.500Z (over 1 year ago)
- Language: JavaScript
- Size: 113 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# Dexpress.js
Dexpress.js is a very basic web framework for nodejs *(similar to expressjs, hence the name)* created for **learning purpose.**
All you can do is
* listen to a particular port
* define simple get and post routes *(no fancy named routes, parameters ... )*.
The idea is to see how one can implement expressjs like routing framework from scratch in nodejs.
### Basic Usage:
*(or usage of this basic framework, whatever)*
```javascript
var dexpress = require("./dexpress.js"), // or from wherever you have placed this js file
app = dexpress();
app.listen(); // default port is "6060"
//or
app.listen("3000"); // sets the port to "3000"
// Define a simple 'GET' route
app.get("/greet", function (request, response) {
response.writeHeader("200", {"Content-Type": "text/html"});
response.end("
Hello Universe
- Greetings from Dexpress!");
});
// Define a simple 'POST' route
app.post("/greet", function (request, response) {
response.writeHeader("200", {"Content-Type": "text/html"});
response.end("Hello Universe - You are posting to greet route
- Greetings from Dexpress!");
});
// you can also define an 'ALL' route that gets called for all request methods
app.all("/greet", function (request, response) {
// do whatever you feel like doing
});
```
I have been using expressjs for some time without even knowing what is possible in nodejs itself, hence this simple project.