updated the readme and moved server.js into server folder
This commit is contained in:
parent
9696ef04dc
commit
348bedfb55
8 changed files with 64 additions and 10949 deletions
33
README.md
33
README.md
|
@ -13,16 +13,41 @@ Spee.ch is a web app that reads and publishes images and videos to and from the
|
|||
* clone this repo
|
||||
* run `npm install`
|
||||
* create your own config files in `/config`
|
||||
* copy `mysqlConfig.js.example` and name it `mysqlConfig.js`
|
||||
* copy `siteConfig.js.example` and name it `siteConfig.js`
|
||||
* replace the `null` values in the config file with the appropriate values for your environment
|
||||
* copy `mysqlConfig.js.example`, name it `mysqlConfig.js`, and update its contents.
|
||||
* copy `siteConfig.js.example`, name it `siteConfig.js`, and update its contents.
|
||||
* build the app by running `npm run build`
|
||||
* for development, `npm run build-dev` will build the app and continue to listen for changes, building again when a change is made.
|
||||
* to start the server, run `npm run start`
|
||||
* visit [localhost:3000](http://localhost:3000)
|
||||
* for development, `npm run start-dev` will start the server and continue to listen for changes, restarting the server again whenever a change is made.
|
||||
* for production, [pm2](http://pm2.keymetrics.io/docs/usage/quick-start/) is a great tool for starting and managing node processes
|
||||
* visit [localhost:3000](http://localhost:3000) and check out your spee.ch app!
|
||||
* start spee.ch-sync (optional, recommended)
|
||||
* Note: this tool will decode blocks from the `lbry` blockchain and update the Claim and Certificate tables in mysql with all the claims from the blockchain. This is not necessary if you only want to host and resolve content published through your version of spee.ch, but it is required if you want to retrieve and host other content from the lbry network.
|
||||
* install and run this [`speech-sync`](https://github.com/billbitt/spee.ch-sync) tool
|
||||
|
||||
## Development & App Structure
|
||||
* the `client/` folder houses all of the `react` and `redux` code.
|
||||
* `client.js` is the entry point for the app. This file is the entry point for webpack to build the client bundle.
|
||||
* `app.jsx` is the parent component that houses the rest of the app components
|
||||
* components are located in `client/components`, `client/containers`, and `client/pages`
|
||||
* `/components` contains the 'dumb' components that receive props (if any) from their parents
|
||||
* `/containers` contains the 'smart' redux-connected components that receive props from the `redux-store`
|
||||
* `/pages` contains the components which act as the main pages of the app
|
||||
* actions are located in the `client/actions` folder
|
||||
* reducers are located in the `client/reducers` folder
|
||||
* sagas are located in the `client/sagas` folder
|
||||
* the `server/` folder contains all of server code.
|
||||
* `server.js` is the entry point for the server. It creates the [express app](https://expressjs.com/), requires the routes, syncs the database, and starts the server listening on the `PORT` designated in the config file. This file is the entry point for webpack to build the server bundle.
|
||||
* the `/routes` folder contains all of the routes for the express app
|
||||
* the `/models` folder contains all of the models which the app uses to interact with the `mysql` database. Note: this app uses the [sequelize](http://docs.sequelizejs.com/) orm.
|
||||
* webpack
|
||||
* During the build process, webpack creates two bundles for this project:
|
||||
* (1) a client-side app bundle which will be located at `public/bundle/bundle.js`
|
||||
* (2) a server bundle which will be located at `server/index.js`
|
||||
* configuration
|
||||
* the `config/` folder contains all of the required config files. The project contains `.example` files which can be copied to create the necessary `.js` files
|
||||
* the `devConfig/` folder contains optional config files. Updating these files is not necessary. If you update these files, make sure to add them to your `.gitignore` file so they are not included in source control.
|
||||
|
||||
## Tests
|
||||
* Spee.ch uses `mocha` with `chai` for testing.
|
||||
* To run all tests that do not require LBC, run `npm test -- --grep @usesLbc --invert`
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
module.exports = {
|
||||
database: 'default',
|
||||
username: 'default',
|
||||
password: 'default',
|
||||
database: 'default', // your mysql database name
|
||||
username: 'default', // your mysql username
|
||||
password: 'default', // your mysql password
|
||||
};
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
module.exports = {
|
||||
analytics: {
|
||||
googleId: 'default',
|
||||
googleId: 'default', // optional: add a google id
|
||||
},
|
||||
assetDefaults: {
|
||||
description: 'An asset published on Spee.ch',
|
||||
thumbnail : 'https://spee.ch/assets/img/video_thumb_default.png',
|
||||
title : 'Spee.ch',
|
||||
description: 'An asset published on Spee.ch', // optional: add a default description for assets on your site
|
||||
thumbnail : 'https://spee.ch/assets/img/video_thumb_default.png', // optional: add a default thumbnail image for assets on your site
|
||||
title : 'Spee.ch', // optional: add a default title for assets on your site
|
||||
},
|
||||
auth: {
|
||||
sessionKey: 'default',
|
||||
sessionKey: 'default', // choose a secret session key
|
||||
},
|
||||
details: {
|
||||
description: 'Open-source, decentralized image and video sharing.',
|
||||
host : 'default',
|
||||
port : 3000,
|
||||
title : 'Spee.ch',
|
||||
twitter : '@spee_ch',
|
||||
description: 'Open-source, decentralized image and video sharing.', // add a description for your site
|
||||
host : 'https://some.cool.site', // add the host of your site (e.g. 'https://spee.ch')
|
||||
port : 3000, // add the port your site should listen on
|
||||
title : 'Spee.ch', // add a title for your site
|
||||
twitter : '@default', // optional: add the twitter handle for your site
|
||||
},
|
||||
publishing: {
|
||||
additionalClaimAddresses: [],
|
||||
disabled : false,
|
||||
disabledMessage : 'Please check back soon.',
|
||||
primaryClaimAddress : 'default',
|
||||
thumbnailChannel : 'default',
|
||||
additionalClaimAddresses: [], // optional: if you have other wallet addresses that you have used to publish from, enter them here
|
||||
disabled : false, // optional: if 'true' this will disable publishing
|
||||
disabledMessage : 'Please check back soon.', // optional: if publishing is disabled, this message will be displayed instead
|
||||
primaryClaimAddress : 'default', // required: choose an address from your lbry wallet and enter it here
|
||||
thumbnailChannel : 'default', //
|
||||
thumbnailChannelId : 'default',
|
||||
uploadDirectory : '/home/lbry/Uploads',
|
||||
},
|
||||
|
|
10909
index.js
10909
index.js
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -6,8 +6,8 @@
|
|||
"scripts": {
|
||||
"test": "mocha --recursive",
|
||||
"test-all": "mocha --recursive",
|
||||
"start": "node index.js",
|
||||
"start-dev": "nodemon index.js",
|
||||
"start": "node server/index.js",
|
||||
"start-dev": "nodemon server/index.js",
|
||||
"lint": "eslint .",
|
||||
"fix": "eslint . --fix",
|
||||
"precommit": "eslint .",
|
||||
|
|
|
@ -6,18 +6,18 @@ const Handlebars = require('handlebars');
|
|||
const helmet = require('helmet');
|
||||
const passport = require('passport');
|
||||
const cookieSession = require('cookie-session');
|
||||
const { serializeSpeechUser, deserializeSpeechUser } = require('./server/helpers/authHelpers.js');
|
||||
const { serializeSpeechUser, deserializeSpeechUser } = require('./helpers/authHelpers.js');
|
||||
const logger = require('winston');
|
||||
|
||||
// require configs
|
||||
const {auth: { sessionKey }, details: { port: PORT }} = require('./config/siteConfig.js');
|
||||
const {auth: { sessionKey }, details: { port: PORT }} = require('../config/siteConfig.js');
|
||||
|
||||
const db = require('./server/models');
|
||||
const db = require('./models/index');
|
||||
|
||||
// configure logging
|
||||
require('./server/helpers/configureLogger.js')(logger);
|
||||
require('./helpers/configureLogger.js')(logger);
|
||||
// configure slack
|
||||
require('./server/helpers/configureSlack.js')(logger);
|
||||
require('./helpers/configureSlack.js')(logger);
|
||||
|
||||
// create an Express application
|
||||
const app = express();
|
||||
|
@ -38,8 +38,8 @@ app.use((req, res, next) => { // custom logging middleware to log all incoming
|
|||
// configure passport
|
||||
passport.serializeUser(serializeSpeechUser);
|
||||
passport.deserializeUser(deserializeSpeechUser);
|
||||
const localSignupStrategy = require('./server/passport/local-signup.js');
|
||||
const localLoginStrategy = require('./server/passport/local-login.js');
|
||||
const localSignupStrategy = require('./passport/local-signup.js');
|
||||
const localLoginStrategy = require('./passport/local-login.js');
|
||||
passport.use('local-signup', localSignupStrategy);
|
||||
passport.use('local-login', localLoginStrategy);
|
||||
// initialize passport
|
||||
|
@ -64,11 +64,11 @@ db.sequelize
|
|||
.sync()
|
||||
.then(() => {
|
||||
// set the routes on the app
|
||||
require('./server/routes/auth-routes.js')(app);
|
||||
require('./server/routes/api-routes.js')(app);
|
||||
require('./server/routes/page-routes.js')(app);
|
||||
require('./server/routes/asset-routes.js')(app);
|
||||
require('./server/routes/fallback-routes.js')(app);
|
||||
require('./routes/auth-routes.js')(app);
|
||||
require('./routes/api-routes.js')(app);
|
||||
require('./routes/page-routes.js')(app);
|
||||
require('./routes/asset-routes.js')(app);
|
||||
require('./routes/fallback-routes.js')(app);
|
||||
// create server
|
||||
const http = require('http');
|
||||
return http.Server(app);
|
|
@ -8,10 +8,10 @@ module.exports = {
|
|||
__dirname: false,
|
||||
},
|
||||
externals: [nodeExternals()],
|
||||
entry : ['babel-polyfill', 'whatwg-fetch', './server.js'],
|
||||
entry : ['babel-polyfill', 'whatwg-fetch', './server/server.js'],
|
||||
output : {
|
||||
path : Path.join(__dirname, '/'),
|
||||
publicPath : '/',
|
||||
path : Path.join(__dirname, 'server/'),
|
||||
publicPath : 'server/',
|
||||
filename : 'index.js',
|
||||
library : '',
|
||||
libraryTarget: 'commonjs-module',
|
||||
|
|
Loading…
Reference in a new issue