<file_sep>import { createServer } from 'http'
import * as next from 'next'
import * as path from 'path'
import { parse } from 'url'
import { validateStaticPath } from './static_assets'

const port = parseInt(process.env.PORT, 10) || 3000
const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })
const handle = app.getRequestHandler()

app.prepare().then(() => {
  createServer((req, res) => {
    const parsedUrl = parse(req.url, true)
    const { pathname } = parsedUrl

    // Next.js server-rendered routes:
    // if (pathname === '/path') app.render(req, res, '/path', query)

    const resolveStatic = validateStaticPath(
      path.join(__dirname, '../static', pathname),
    )

    if (!!resolveStatic) {
      app.serveStatic(req, res, resolveStatic)
    } else {
      handle(req, res, parsedUrl)
    }
  }).listen(port, () => {
    console.log(`> Ready on http://localhost:${port}`)
  })
})
<file_sep>import MapboxGL from 'mapbox-gl'

export const setAccessToken = (token: string | undefined) => {
  if (token) {
    (MapboxGL as any).accessToken = token
    return true
  } else {
    throw new Error('Mapbox token is unset.')
  }
}
<file_sep>export const skills = [
  {
    label: 'TypeScript',
    url: 'https://www.typescriptlang.org/',
  },
  {
    label: 'Elixir',
    url: 'https://elixir-lang.org/',
  },
  {
    label: 'Phoenix',
    url: 'https://phoenixframework.org/',
  },
  {
    label: 'React.js',
    url: 'https://reactjs.org/',
  },
  {
    label: 'PostgreSQL',
    url: 'https://www.postgresql.org/',
  },
  {
    label: 'SQL',
  },
  {
    label: 'Elm',
    url: 'https://elm-lang.org/',
  },
  {
    label: 'Node.js',
    url: 'https://nodejs.org/',
  },
  {
    label: 'Ruby',
    url: 'https://www.ruby-lang.org/',
  },
  {
    label: 'Rails',
    url: 'https://rubyonrails.org/',
  },
  {
    label: 'PHP',
    url: 'http://www.php.net/',
  },
  {
    label: 'Bash',
    url: 'https://www.gnu.org/software/bash/',
  },
  {
    label: 'GraphQL',
    url: 'https://graphql.org/',
  },
  {
    label: 'RESTful Design',
  },
  {
    label: 'webpack',
    url: 'https://webpack.js.org/',
  },
  {
    label: 'npm',
    url: 'https://www.npmjs.com/',
  },
  {
    label: 'Amazon Web Services',
    url: 'https://aws.amazon.com/',
  },
  {
    label: 'Docker',
    url: 'https://www.docker.com/',
  },
  {
    label: 'CI/CD',
  },
  {
    label: 'Unit & Integration Testing',
  },
  {
    label: 'Functional Programming',
    url: 'https://wikipedia.org/wiki/Functional_programming',
  },
  {
    label: 'Scrum & Kanban Methodologies',
  },
  {
    label: 'Test Driven Development',
  },
  {
    label: 'UX Design',
  },
  {
    label: 'WordPress',
    url: 'https://wordpress.org/',
  },
  {
    label: 'Google Analytics',
    url: 'https://analytics.google.com/',
  },
]

export const interests = [
  '✈️Travel',
  '🐠Scuba Diving',
  '🏋🏼‍♂️CrossFit',
  '🚴🏼‍♂️Cycling',
  '🏄🏼‍♂️ Surfing',
  '🛶 Kayaking',
  '🌳 Outdoors',
  '🐘Alabama Football 🏈',
  '🐷 BBQ',
  '🌴 <NAME>',
  '🎸 Music History',
]
<file_sep>export const IS_PROD = process.env.NODE_ENV === 'production'
export const GTM_CONTAINER_ID = '133182568-1'
export const GTM_SRC_URL = `https://www.googletagmanager.com/gtag/js?id=${GTM_CONTAINER_ID}`

export const GOOGLE_FONTS_BASE_URL = 'https://fonts.googleapis.com/css?family='
export const GOOGLE_FONTS = [
  'Ubuntu+Mono',
  'Playfair+Display',
  'Raleway:400,600,800',
]
<file_sep>//
// @todo: iOS app in React Native to persist coordinates
// from phone locations services, once data store configured.
//

type Cities =
  | 'bogota'
  | 'london'
  | 'medellin'
  | 'summerdale'
  | 'dc'
  | 'sanandres'
  | 'santamarta'
  | 'cartagena'
  | 'cdmx'
  | 'cabo'

export interface ICoord {
  lat: number
  lng: number
}

export type ICoordinates = { [key in Cities]: ICoord }

export const coordinates: ICoordinates = {
  bogota: {
    lat: 4.711,
    lng: -74.072,
  },
  london: {
    lat: 51.489,
    lng: -0.144,
  },
  medellin: {
    lat: 6.244,
    lng: -75.581,
  },
  summerdale: {
    lat: 30.4877,
    lng: -87.6997,
  },
  dc: {
    lat: 38.9,
    lng: -77.03,
  },
  sanandres: {
    lat: 12.57,
    lng: -81.7,
  },
  santamarta: {
    lat: 11.24,
    lng: -74.21,
  },
  cartagena: {
    lat: 10.39,
    lng: -75.48,
  },
  cdmx: {
    lat: 19.43,
    lng: -99.13,
  },
  cabo: {
    lat: 22.89,
    lng: -109.91,
  },
}

const CURRENT_CITY = process.env.CURRENT_CITY as Cities

export const current = coordinates[CURRENT_CITY] || coordinates.london

export default coordinates
<file_sep>import { existsSync } from 'fs'
import * as path from 'path'

const ALLOWED_STATIC_EXT = [
  '.ico',
  '.png',
  '.jpg',
  '.gif',
  '.webmanifest',
  '.txt',
  '.xml',
]

export const validateStaticPath = (pathname: string): false | string => {
  const ext = path.extname(pathname)
  const exists = existsSync(pathname)

  if (ALLOWED_STATIC_EXT.includes(ext) && exists) {
    return pathname
  } else {
    return false
  }
}
<file_sep># <NAME>

> Personal Portfolio Web Application

[https://jaredhugh.es](https://jaredhugh.es)

Based on [Next.js Custom server with TypeScript + Nodemon example](https://github.com/zeit/next.js/tree/canary/examples/custom-server-typescript).

### Usage

- `npm run dev`: Start the application locally in development mode
- `npm run build`: Compile and output static application to `dist`
- `npm start`: Compile the application and start the HTTP server
