diff options
| author | Adam Soltys <[email protected]> | 2018-01-28 21:21:53 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2018-01-28 21:21:53 -0800 |
| commit | 5e19d99e48b9c323ecf3795ea77f1e7e7885e4f5 (patch) | |
| tree | 820ce6151258f8e7879edd3615ee331e52b24486 /app.js | |
| parent | 3a26111203f406bd94a2603fe8793c2e5becb737 (diff) | |
| download | coinos-server-5e19d99e48b9c323ecf3795ea77f1e7e7885e4f5.tar.gz coinos-server-5e19d99e48b9c323ecf3795ea77f1e7e7885e4f5.zip | |
use sequelize and mysql
Diffstat (limited to 'app.js')
| -rw-r--r-- | app.js | 39 |
1 files changed, 2 insertions, 37 deletions
@@ -10,42 +10,13 @@ import fs from 'fs' import grpc from 'grpc' import passport from './passport' import { graphqlExpress, graphiqlExpress } from 'apollo-server-express' -const { makeExecutableSchema } = require('graphql-tools'); - -// Some fake data -const books = [ - { - title: "Harry Potter and the Sorcerer's stone", - author: 'J.K. Rowling', - }, - { - title: 'Jurassic Park', - author: 'Michael Crichton', - }, -]; - -// The GraphQL schema in string form -const typeDefs = ` - type Query { books: [Book] } - type Book { title: String, author: String } -`; - -// The resolvers -const resolvers = { - Query: { books: () => books }, -}; - -// Put together a schema -const schema = makeExecutableSchema({ - typeDefs, - resolvers, -}); dotenv.config() const l = console.log ;(async () => { const app = express() + const db = await require('./db.js') app.enable('trust proxy') app.use(bodyParser.urlencoded({ extended: true })) app.use(bodyParser.json()) @@ -54,18 +25,12 @@ const l = console.log app.use(compression()) app.use(passport.initialize()) - const users = require('./routes/users') - const transactions = require('./routes/transactions') const restClient = ba.restfulClient(process.env.BITCOINAVERAGE_PUBLIC, process.env.BITCOINAVERAGE_SECRET) const lnrpc = await require('lnrpc')({ server: 'localhost:10001' }) const adminMacaroon = fs.readFileSync('/home/adam/.lnd/data/core_test/admin.macaroon'); const meta = new grpc.Metadata(); meta.add('macaroon', adminMacaroon.toString('hex')); - app.post('/login', users.login) - app.post('/users', users.create) - app.get('/verify/:token', users.verify) - app.get('/secret', passport.authenticate('jwt', { session: false }), users.secret) app.get('/balance', async (req, res) => { res.json(await lnrpc.walletBalance({witness_only: true}, meta)) }) @@ -83,7 +48,7 @@ const l = console.log }) app.use('/graphql', bodyParser.json(), graphqlExpress({ - schema: schema, + schema: db.gqlschema, context: {}, tracing: true, cacheControl: true, |
