https://github.com/richplastow/cors-server
A test CORS server, written in NodeJS, deployed to OpenShift
https://github.com/richplastow/cors-server
Last synced: 4 months ago
JSON representation
A test CORS server, written in NodeJS, deployed to OpenShift
- Host: GitHub
- URL: https://github.com/richplastow/cors-server
- Owner: richplastow
- License: mit
- Created: 2015-06-02T22:16:23.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2015-06-04T00:50:50.000Z (about 10 years ago)
- Last Synced: 2025-01-06T01:10:54.007Z (5 months ago)
- Language: JavaScript
- Size: 148 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Cors Server
===========#### A test CORS server, written in NodeJS, deployed to OpenShift
Repo Setup
----------This project has a GitHub repo (which is useful for storing and sharing code), and an OpenShift
repo (which contains the code which actually runs). It uses three branches:- `gh-pages` used to display a static project page
- `dev` contains unstable development releases
- `master` contains stable production releases#### The setup process:
1. In GitHub, create a new repo named 'cors-server', and add 'dev' and 'gh-pages' branches
2. Clone it to your local machine, `git clone https://github.com/richplastow/cors-server.git`
3. Create the packages.json, `cd cors-server/; npm init`
4. Add a field to the "scripts" section of packages.json, `"start": "supervisor index.js"`
5. Create an initial index.js file, just enough to establish that the host's running (see below)
6. Test locally, `node index.js`
7. Add packages.json and index.js to the master branch, commit, and push to GitHub
8. In the [Openshift Applications tab,](https://openshift.redhat.com/app/console/applications)
click 'Add Application'
9. Choose 'Node.js 0.10'
10. Public URL `http://cors-.rhcloud.com/`
11. Source Code `https://github.com//cors-server`
12. Branch/tag: 'master'
13. Click 'Create Application'
14. Browse to `http://cors-.rhcloud.com/` to test the host is running
15. `git remote add live -f ssh://[email protected]/~/git/cors.git/`
16. `git merge live/master -s recursive -X ours`, [see here](http://stackoverflow.com/a/12669112)
17. Make a minor amend to index.js which will be visible when the server is updated and restarts
18. `git push live HEAD`, which should show a couple of dozen lines about build and deployment
19. After `remote: Deployment completed with status: success`, a browser refresh shows the update
20. Backup to GitHub, `git push`@todo dev and gh-pages setup, and .gitignore
#### The initial index.js file:
```javascript
//// Get OpenShift variables, if available.
//// See https://developers.openshift.com/en/node-js-project-structure.html
var port = process.env.OPENSHIFT_NODEJS_PORT || 1337;
var ip = process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1';//// Start running a simple server.
var http = require('http');
var tally = 0;
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Request tally: ' + (++tally) + '\n');
}).listen(port, ip);
console.log('Server running at http://' + ip + ':' + port + '/');
```