Skip to content

Instantly share code, notes, and snippets.

View kluu1's full-sized avatar

Kevin Luu kluu1

  • Atlanta, GA
View GitHub Profile
@kluu1
kluu1 / app.js
Last active March 31, 2020 15:26
const ApiBuilder = require('claudia-api-builder');
const api = new ApiBuilder();
api.get('/hello', req => {
const randomNumber = Math.floor(Math.random() * 10);
const message = `Hello ${req.queryString.name}. Your lucky number is ${randomNumber}`;
return message;
});
const { gql } = require('apollo-server');
const typeDefs = gql`
type Orders {
_id: String!
userId: Int!
amount: Int!
tax: Int!
createdAt: String!
}
const orders = [
{
_id: '5d35f11f56104d59a05f21d4',
userId: 1778,
amount: 600,
tax: 60,
createdAt: '1563816223063.0',
},
{
_id: '5d383702280bb47f048ace35',
const orders = require('../data');
const resolvers = {
Query: {
orders: (_, args) => {
return orders;
}
},
const { GraphQLScalarType } = require('graphql') ;
const { Kind } = require('graphql/language');
const orders = require('../db');
const resolvers = {
Query: {
orders: (_, args) => {
return orders;
}
},
const { gql } = require('apollo-server');
const typeDefs = gql`
scalar Date
type Orders {
userId: Int!
amount: Int!
createdAt: Date!
}
@kluu1
kluu1 / db.js
Last active April 2, 2020 10:52
const orders = [
{
userId: 1778,
amount: 600,
createdAt: '1563816223063.0',
},
{
userId: 1781,
amount: 250,
createdAt: '1563965186852.0',
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
const port = 3000;
app.use(bodyParser.json());
app.post('/post', async (req, res) => {
const { title, author } = req.body;
@kluu1
kluu1 / app.js
Created April 2, 2020 12:47
final
const express = require('express');
const bodyParser = require('body-parser');
const handleErrors = require('./middleware/handleErrors');
const { BadRequest } = require('./utils/errors');
const app = express();
const port = 3000;
app.use(bodyParser.json());
const express = require('express');
const bodyParser = require('body-parser');
const handleErrors = require('./middleware/handleErrors');
const { BadRequest } = require('./utils/errors');
const app = express();
const port = 3000;
app.use(bodyParser.json());