This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import | |
React,{Component | |
}from 'react'; | |
import {Route,Switch} from 'react-router'; | |
import {Link} from 'react-router-dom'; | |
import {ConnectedRouter} from 'connected-react-router'; | |
import {history} from './store'; | |
import {Provider} from 'react-redux'; | |
import {configureStore} from './store'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
![Captura](https://user-images.githubusercontent.com/29363763/77968943-1213a080-72d8-11ea-97b6-b44a5e812006.PNG) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import express, { Application } from 'express'; | |
import { ApolloServer , Config } from 'apollo-server-express'; | |
const app: Application = express(); | |
const schema = ` | |
type User{ | |
name: String |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
const {CheckerPlugin} = require('awesome-typescript-loader'); | |
var nodeExternals = require('webpack-node-externals'); | |
module.exports = { | |
mode: 'production', | |
entry: './src/index.ts', | |
target:'node', | |
externals: [nodeExternals(),{ knex: 'commonjs knex' }], | |
output: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"compilerOptions": { | |
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ | |
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ | |
/* Concatenate and emit output to single file. */ | |
"outDir": "dist", /* Redirect output structure to the directory. */ | |
"rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ | |
"strict": true, /* Enable all strict type-checking options. */ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as Knex from "knex"; | |
export async function up(knex: Knex): Promise<any> { | |
return knex.schema.createTable('users',(table:Knex.CreateTableBuilder)=>{ | |
table.increments('id'); | |
table.string('full_name',36); | |
table.integer('country_code'); | |
table.timestamps(true,true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('ts-node/register'); | |
module.exports = { | |
development:{ | |
client: 'pg', | |
connection: { | |
database: "my_db", | |
user: "username", | |
password: "password" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Model} from 'objection'; | |
import {Species,Maybe} from '../../__generated__/generated-types'; | |
import User from './User'; | |
class Pet extends Model{ | |
static tableName = "pets"; | |
id! : number; | |
name?: Maybe<string>; | |
specie?: Maybe<Species>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Species{ | |
BIRDS, | |
FISH, | |
MAMMALS, | |
REPTILES | |
} | |
type User { | |
id: Int! | |
full_name: String |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Pet,User} from '../../database/models'; | |
import {Resolvers} from '../../__generated__/generated-types'; | |
import {UserInputError} from 'apollo-server-express'; | |
const resolvers : Resolvers = { | |
Query:{ | |
pet:async (parent,args,ctx)=>{ | |
const pet:Pet= await Pet.query().findById(args.id); |
OlderNewer