Skip to content

Commit

Permalink
Begin rewrite from GraphQL to REST based API
Browse files Browse the repository at this point in the history
Special thanks to @javieraviles for the node-typescript-koa-rest boilerplate

https://github.com/javieraviles/node-typescript-koa-rest
  • Loading branch information
mitchdowney committed Sep 15, 2018
1 parent 5612660 commit c657997
Show file tree
Hide file tree
Showing 34 changed files with 721 additions and 1,252 deletions.
4 changes: 4 additions & 0 deletions .example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
PORT=3000
NODE_ENV=development
JWT_SECRET=your-secret-whatever
DATABASE__URL=postgres://postgres:mysecretpw@localhost:5432/postgres
69 changes: 14 additions & 55 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,63 +1,22 @@
/src/config/google/jwt.keys.json

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# API keys and secrets
.env

# Bower dependency directory (https://bower.io/)
# Dependency directory
node_modules
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Editors
.idea
*.iml

# Dependency directories
node_modules/
jspm_packages/
# OS metadata
.DS_Store
Thumbs.db

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
# Ignore built ts files
dist/**/*

# next.js build output
.next
# Logging files
*.log
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"language": "node_js",
"node_js": "8",
"script": [
"npm run build",
"npm run test"
]
}
5 changes: 0 additions & 5 deletions nodemon.json

This file was deleted.

59 changes: 44 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,36 +1,65 @@
{
"name": "podverse-api",
"version": "1.0.0",
"description": "Data API, database migration scripts, and backend services for all Podverse models.",
"main": "dist/server.js",
"scripts": {
"addAllFeedsToQueue": "ts-node -r tsconfig-paths/register ./src/scripts/queue/addAllFeedsToQueue.ts",
"parseFeed": "ts-node -r tsconfig-paths/register ./src/scripts/parser/parseFeed.ts",
"parseAllFeedsFromQueue": "ts-node -r tsconfig-paths/register ./src/scripts/parser/parseAllFeedsFromQueue.ts",
"queryUniquePageviews": "ts-node -r tsconfig-paths/register ./src/scripts/stats/queryUniquePageviews.ts",
"receiveNextFeedFromQueue": "ts-node -r tsconfig-paths/register ./src/scripts/queue/receiveNextFeedFromQueue.ts",
"start": "nodemon"
"watch-server": "nodemon --watch 'src/**/*' -e ts,tsx --exec ts-node -r tsconfig-paths/register src/server.ts"
},
"dependencies": {
"license": "AGPLv3",
"homepage": "https://github.com/podverse/podverse-api#readme",
"keywords": [
"podcast",
"episode",
"RSS",
"Atom",
"feed",
"parser",
"feedparser",
"database",
"db",
"sequelize",
"podverse"
],
"devDependencies": {
"@types/dotenv": "^4.0.3",
"@types/google.analytics": "^0.0.39",
"@types/koa": "^2.0.46",
"@types/koa-bodyparser": "^5.0.1",
"@types/koa-helmet": "^3.1.2",
"@types/koa-jwt": "^3.3.0",
"@types/koa-router": "^7.0.31",
"@types/koa__cors": "^2.2.3",
"@types/node": "^10.9.4",
"apollo-errors": "^1.9.0",
"apollo-server-koa": "^2.0.5",
"aws-sdk": "^2.311.0",
"@types/shelljs": "^0.8.0",
"nodemon": "^1.18.4",
"ts-node": "^7.0.1",
"tslint": "^5.11.0",
"tslint-config-standard": "^8.0.1",
"typescript": "^3.0.3"
},
"dependencies": {
"@koa/cors": "^2.2.2",
"aws-sdk": "^2.315.0",
"class-validator": "^0.9.1",
"googleapis": "^33.0.0",
"graphql": "^14.0.0",
"koa": "^2.5.2",
"koa": "^2.5.3",
"koa-bodyparser": "^4.2.1",
"koa-helmet": "^4.0.0",
"koa-jwt": "^3.5.1",
"koa-router": "^7.4.0",
"merge-graphql-schemas": "^1.5.3",
"node-podcast-parser": "^2.3.0",
"nodemon": "^1.18.4",
"pg": "^7.4.3",
"reflect-metadata": "^0.1.12",
"pg-connection-string": "^2.0.0",
"request": "^2.88.0",
"shortid": "^2.2.13",
"ts-node": "^7.0.1",
"tsconfig-paths": "^3.5.0",
"tslint": "^5.11.0",
"tslint-config-standard": "^8.0.1",
"tsconfig-paths": "^3.6.0",
"typeorm": "^0.2.7",
"typescript": "^3.0.3"
"winston": "^3.1.0"
}
}
52 changes: 28 additions & 24 deletions src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
import { ConnectionOptions } from 'typeorm'
import * as dotenv from 'dotenv'

const env = process.env
dotenv.config({ path: '.env' })

export const awsConfig = {
queueUrls: {
feedsToParse: env.AWS_QUEUE_FEED_PARSER_URL,
feedsToParseErrors: env.AWS_QUEUE_FEED_PARSER_ERRORS_URL
},
region: env.AWS_REGION
interface EntityRelationships {
mediaRef: {
mustHavePodcast: boolean
mustHaveUser: boolean
}
}

export const dbConfig = {
database: 'postgres',
host: env.DB_HOST || '0.0.0.0',
log: {
query: env.DB_LOG_QUERIES || true
},
password: env.DB_PASSWORD || 'mysecretpw',
port: env.DB_PORT || 5432,
synchronize: env.DB_SYNCHRONIZE || true,
type: 'postgres',
username: env.DB_USERNAME || 'postgres'
} as ConnectionOptions
export interface IConfig {
port: number
debugLogging: boolean
dbsslconn: boolean
jwtSecret: string
databaseUrl: string
entityRelationships: EntityRelationships
}

export const entityRelationships = {
mediaRef: {
mustHavePodcast: env.MEDIA_REF_HAS_PODCAST || false,
mustHaveUser: env.MEDIA_REF_HAS_USER || false
const config: IConfig = {
port: +process.env.PORT || 3000,
debugLogging: process.env.NODE_ENV === 'development',
dbsslconn: process.env.NODE_ENV !== 'development',
jwtSecret: process.env.JWT_SECRET || 'your-secret-whatever',
databaseUrl: process.env.DATABASE_URL || 'postgres://postgres:mysecretpw@localhost:5432/postgres',
entityRelationships: {
mediaRef: {
mustHavePodcast: process.env.MEDIA_REF_HAS_PODCAST === 'true',
mustHaveUser: process.env.MEDIA_REF_HAS_USER === 'true'
}
}
}

export { config }
9 changes: 9 additions & 0 deletions src/controller/general.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { BaseContext } from 'koa'

export default class GeneralController {

public static async helloWorld (ctx: BaseContext) {
ctx.body = 'Hellloooo world!'
}

}
1 change: 1 addition & 0 deletions src/controller/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as general } from './general'
3 changes: 2 additions & 1 deletion src/entities/mediaRef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { BeforeInsert, Column, CreateDateColumn, Entity, JoinColumn,
BeforeUpdate } from 'typeorm'
import { Author, Category, Episode, Playlist, Podcast, User } from 'entities'

import { entityRelationships } from 'config'
import { config } from 'config'
const { entityRelationships } = config
const { mustHavePodcast, mustHaveUser } = entityRelationships.mediaRef

const shortid = require('shortid')
Expand Down
19 changes: 0 additions & 19 deletions src/graphql/resolvers/author.ts

This file was deleted.

19 changes: 0 additions & 19 deletions src/graphql/resolvers/category.ts

This file was deleted.

19 changes: 0 additions & 19 deletions src/graphql/resolvers/episode.ts

This file was deleted.

19 changes: 0 additions & 19 deletions src/graphql/resolvers/feedUrl.ts

This file was deleted.

6 changes: 0 additions & 6 deletions src/graphql/resolvers/index.ts

This file was deleted.

41 changes: 0 additions & 41 deletions src/graphql/resolvers/mediaRef.ts

This file was deleted.

Loading

0 comments on commit c657997

Please sign in to comment.