Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
  modules
  dist
  lib
  test
  package.json
  .npmignore
  authentication.js
  database.js
  debug.js
  app.js
  jsonbody.js
  navigation.js
  route-builder.js
  index.js
  sendmail.js
  session.js
  express.js
  .babelrc
  readme.md
  .eslintrc.yml
  .release
Size: Mime:
  readme.md

Touchto Core Readme

Install Requirements.

node, npm, docker

Part 1. Basic installation

  • npm init config
  • installing Node modules
  • creating routes
  • creating js files
  • creating html files
  • hello world web app serving
  • basic debug configuration*
  • creating css files*

Make base project directory and create a file.

  1. mkdir ${PROJECT_NAME}
  2. touch .npmrc
registry=https://npm-proxy.fury.io/bixqGu-AWRynjiisoc9n/touchto/
strict-ssl=true
ca=

Add these contents above

  1. npm init, follow on screen
  2. inside package.json find and replace the “scripts” declaration in package.js with:
"scripts": {
    "start": "node ${npm_package_main}",
    "debug": "DEBUG=touchto* DEBUG_COLORS=1 node ${npm_package_main}"
}
  1. npm install --save touchto-core This command d/l’s a slew of node modules necessary for TouchTo-core into the node_modules directory.

In base project directory 6. index.js

#!/usr/bin/env node

var express = require('express');
var debug = require('debug')('touchto:server');
var app = require('touchto-core/app');

var http = require('http').Server(app);
require('touchto-core/database');
server = http.listen(3000, function(){
            debug('HTTP listenting at: %s', server.address().port);
});

At this point you have a fully capable installation of Touchto Core. You can test it by running it with npm start or npm run debug

Example console output after going to localhost:3000 on your browser npm start

WARNING: No configurations found in configuration directory:...config
WARNING: To disable this warning set SUPPRESS_NO_CONFIG_WARNING in the environment.
GET / 404 4.453 ms - 9

You get a 404 response because Touchto Core is configured to use endpoints housed in server/routes-open/ server/routes-rest-open/ —and— server/routes/ server/routes-rest

Let’s make a public route in server/routes-open/. There is a numerical naming convention for routes files. Start with 000-.js and progress to 001-.js onward.

  1. mkdir -p server/routes-open

  2. touch server/routes-open/000-index.js

var base, debug, express, namespace, path, router;
path = require('path');
namespace = path.basename(path.dirname(module.filename));
base = path.basename(module.filename, path.extname(module.filename)).match(/^(?:\d{0,}-)?(.+)/)[1];
debug = require('debug')("touchto:" + namespace + ":" + base);

express = require('express');

router = express.Router({
        caseSensitive: true
});

router.get('/', function(req, res, next) {
        res.send('Howdy!');
});

debug('Router instance ready');
module.exports = router;

Now let’s make a new endpoint/webpage and the html, css, and js for it. First we’ll need to create some directories.

  1. mkdir -p client/scripts <— JS

  2. mkdir -p server/views <— HTML

  3. mkdir -p client/styles <— CSS

  4. touch server/routes-open/001-foo.js

  5. touch client/scripts/main.js

  6. touch server/views/hello.html

  7. Add the following line to our previously created 000-index.js file AFTER the declaration of the router variable:

router.use('/js', express.static(path.join(__dirname,'../../client/scripts')));

This line tells the app router where client requested js files are located.

  1. Copy/Paste into 001-foo.js file:
var base, debug, express, namespace, path, router;
path = require('path');
namespace = path.basename(path.dirname(module.filename));
base = path.basename(module.filename, path.extname(module.filename)).match(/^(?:\d{0,}-)?(.+)/)[1];
debug = require('debug')("touchto:" + namespace + ":" + base);

express = require('express');

router = express.Router({
        caseSensitive: true
});

router.get('/', function(req, res, next) {
        res.render('hello');
});

debug('Router instance ready');
module.exports = router;
  1. Copy/Paste into main.js:
console.log(‘You got some js running!’);
  1. Copy/Paste into hello.html:
<script src="js/main.js"></script>
<p> Heyup! </p>
  1. You will now have a new route at localhost:3000/foo. Stop and restart the app with: Ctrl-C then, npm start or npm run debug and refresh the page and you should get a Heyup! along with console output in your dev console.

Part 2. Running it with Docker

If you have docker installed you can dev through a running docker image. This is preferred for portability reasons.
From the your Touchto Core base directory.

  1. docker run --name touchto-core --rm -it -p 80:3000 -v "$PWD":/app -w /app node:alpine sh

Command Explanation: Run a docker named touchto-core, remove it after exits, give it a terminal, forward app port 3000 to host port 80, share local volume PWD (Touchto app directory) with docker image directory /app, make the working directory /app, base the image off node:alpine in hub, and give user a sh shell prompt.

Once it’s running type npm start. Go to localhost and localhost/foo.

If the --port number is not the default 80, aka. 8080:3000, then goto localhost:8080.

Part 3. Database Configuration

Part 4. Authentication Configuration