profile
viewpoint
Allen Hai coetry @zeit Houston (&& code poetry)

issue commentzeit/now-cli

[now dev] 15.4.0 local server not running after compilation

@michelalbers 15.5.0 seems to be working fine for me as well. Are you still experiencing problems with a particular repo? If so, can you share a link here?

coetry

comment created time in a day

issue commentzeit/now-cli

[now dev] 15.4.0 local server not running after compilation

@michelalbers yeah 15.2.0 works for me as well. I believe its that last version that doesn't use the new file watcher.

coetry

comment created time in 2 days

startedmjackson/rollup-plugin-url-resolve

started time in 4 days

issue commentzeit/now-cli

[now dev] 15.4.0 local server not running after compilation

I upgraded to 15.4.0-canary.3 dev and the problem persists

Screen Shot 2019-06-09 at 11 28 46 PM

coetry

comment created time in 6 days

issue openedzeit/now-cli

[now dev] 15.4.0 local server not running after compilation

After running now dev from project root, no local server is started upon successful compilation. Previous talks with @TooTallNate have suggested chokidar to be a possible culprit (compilation completion event not firing properly for certain machines).

Screen Shot 2019-06-09 at 11 22 19 PM Screen Shot 2019-06-09 at 11 22 34 PM

created time in 6 days

startednice-boys/product-boilerplate

started time in 8 days

startedzeit/next-plugins

started time in 18 days

startedzeit/styled-jsx

started time in 20 days

push eventzeit/integrations

Allen Hai

commit sha b212997f0d4115fabea30aa014b6dcab6ca18e88

init

view details

push time in 23 days

create barnchzeit/integrations

branch : add/acme-starter-kit

created branch time in 23 days

Pull request review commentzeit/now-builders

Add @now/ruby

+require 'webrick'+require 'net/http'+require 'base64'+require 'json'++require 'httparty'++require_relative '__NOW_HANDLER_FILENAME'++SupportedHTTPMethods = {+  'GET' => Net::HTTP::Get,+  'POST' => Net::HTTP::Post,+  'PATCH' => Net::HTTP::Patch,+  'PUT' => Net::HTTP::Put,+  'DELETE' => Net::HTTP::Delete,+  'HEAD' => Net::HTTP::Head,+  'OPTIONS' => Net::HTTP::Options,+  'MOVE' => Net::HTTP::Move,+  'COPY' => Net::HTTP::Copy,+  'MKCOL' => Net::HTTP::Mkcol,+  'LOCK' => Net::HTTP::Lock,+  'UNLOCK' => Net::HTTP::Unlock,+}++def now__handler(event:, context:)+  if not Object.const_defined?('Handler')+    return { :statusCode => 500, :body => 'Handler not defined in lambda' }+  end++  payload = JSON.parse(event['body'])+  path = payload['path']+  headers = payload['headers']+  httpMethod = payload['method']+  encoding = payload['encoding']+  body = payload['body']++  if not SupportedHTTPMethods.key?(httpMethod)+    return { :statusCode => 405, :body => 'Method Not Allowed' }+  end++  if (not body.nil? and not body.empty?) and (not encoding.nil? and encoding == 'base64')+    body = Base64.decode64(body)+  end++  server = WEBrick::HTTPServer.new :BindAddress => "0.0.0.0", :Port => 3000++  if Handler.is_a?(Proc)+    server.mount_proc '/', Handler+  else+    server.mount '/', Handler+  end++  shut = proc {server.shutdown}++  Signal.list.keys.each do |sig|+    begin+      Signal.trap(sig, shut)+    rescue+    end+  end++  Thread.new(server) do |server|+    server.start+  end++  req = HTTParty::Request.new(+    SupportedHTTPMethods[httpMethod],

Here's a nice article that touches on metaprogramming in Ruby: https://azemoh.com/2017/01/31/metaprogramming-invoking-methods/

nathancahill

comment created time in 23 days

Pull request review commentzeit/now-builders

Add @now/ruby

+require 'webrick'+require 'net/http'+require 'base64'+require 'json'++require 'httparty'++require_relative '__NOW_HANDLER_FILENAME'++SupportedHTTPMethods = {+  'GET' => Net::HTTP::Get,+  'POST' => Net::HTTP::Post,+  'PATCH' => Net::HTTP::Patch,+  'PUT' => Net::HTTP::Put,+  'DELETE' => Net::HTTP::Delete,+  'HEAD' => Net::HTTP::Head,+  'OPTIONS' => Net::HTTP::Options,+  'MOVE' => Net::HTTP::Move,+  'COPY' => Net::HTTP::Copy,+  'MKCOL' => Net::HTTP::Mkcol,+  'LOCK' => Net::HTTP::Lock,+  'UNLOCK' => Net::HTTP::Unlock,+}++def now__handler(event:, context:)+  if not Object.const_defined?('Handler')+    return { :statusCode => 500, :body => 'Handler not defined in lambda' }+  end++  payload = JSON.parse(event['body'])+  path = payload['path']+  headers = payload['headers']+  httpMethod = payload['method']+  encoding = payload['encoding']+  body = payload['body']++  if not SupportedHTTPMethods.key?(httpMethod)+    return { :statusCode => 405, :body => 'Method Not Allowed' }+  end++  if (not body.nil? and not body.empty?) and (not encoding.nil? and encoding == 'base64')+    body = Base64.decode64(body)+  end++  server = WEBrick::HTTPServer.new :BindAddress => "0.0.0.0", :Port => 3000++  if Handler.is_a?(Proc)+    server.mount_proc '/', Handler+  else+    server.mount '/', Handler+  end++  shut = proc {server.shutdown}++  Signal.list.keys.each do |sig|+    begin+      Signal.trap(sig, shut)+    rescue+    end+  end++  Thread.new(server) do |server|+    server.start+  end++  req = HTTParty::Request.new(+    SupportedHTTPMethods[httpMethod],

@nathancahill you and send methods to Ruby classes dynamically via the .send method.

require 'net/http'
Net::HTTP.send("get", URI('https://github.com'))
nathancahill

comment created time in 23 days

Pull request review commentzeit/now-builders

Add @now/ruby

+require 'webrick'+require 'net/http'+require 'base64'+require 'json'++require 'httparty'++require_relative '__NOW_HANDLER_FILENAME'++SupportedHTTPMethods = {+  'GET' => Net::HTTP::Get,+  'POST' => Net::HTTP::Post,+  'PATCH' => Net::HTTP::Patch,+  'PUT' => Net::HTTP::Put,+  'DELETE' => Net::HTTP::Delete,+  'HEAD' => Net::HTTP::Head,+  'OPTIONS' => Net::HTTP::Options,+  'MOVE' => Net::HTTP::Move,+  'COPY' => Net::HTTP::Copy,+  'MKCOL' => Net::HTTP::Mkcol,+  'LOCK' => Net::HTTP::Lock,+  'UNLOCK' => Net::HTTP::Unlock,+}++def now__handler(event:, context:)+  if not Object.const_defined?('Handler')+    return { :statusCode => 500, :body => 'Handler not defined in lambda' }+  end++  payload = JSON.parse(event['body'])+  path = payload['path']+  headers = payload['headers']+  httpMethod = payload['method']+  encoding = payload['encoding']+  body = payload['body']++  if not SupportedHTTPMethods.key?(httpMethod)+    return { :statusCode => 405, :body => 'Method Not Allowed' }+  end++  if (not body.nil? and not body.empty?) and (not encoding.nil? and encoding == 'base64')+    body = Base64.decode64(body)+  end++  server = WEBrick::HTTPServer.new :BindAddress => "0.0.0.0", :Port => 3000++  if Handler.is_a?(Proc)+    server.mount_proc '/', Handler+  else+    server.mount '/', Handler+  end++  shut = proc {server.shutdown}++  Signal.list.keys.each do |sig|+    begin+      Signal.trap(sig, shut)+    rescue+    end+  end++  Thread.new(server) do |server|+    server.start+  end++  req = HTTParty::Request.new(+    SupportedHTTPMethods[httpMethod],

@nathancahill I would really encourage cutting out third party libs as much as possible. Can you elaborate on what you mean by arbitrary methods?

https://docs.ruby-lang.org/en/2.0.0/Net/HTTP.html

nathancahill

comment created time in 23 days

fork coetry/the-art-of-command-line

Master the command line, in one page

fork in 24 days

startedjlevy/the-art-of-command-line

started time in 24 days

startedblokboy/UniswapBot

started time in 24 days

starteddustinmyers/react-conflux

started time in 24 days

startedzeit/now-builders

started time in 24 days

startedy2q-actionman/cl-aws-custom-runtime-test

started time in 25 days

delete branch zeit/integrations

delete branch : update/oceanbase

delete time in 25 days

push eventzeit/integrations

Allen Hai

commit sha 49124e8342e353f1886a2f46022a63f372bd7090

update oceanbase

view details

Allen Hai

commit sha 323bd3269f174e567fddc410ddf2ab8bf5a15dc6

Merge pull request #7 from zeit/update/oceanbase update oceanbase to latest iteration

view details

push time in 25 days

PR merged zeit/integrations

Reviewers
update oceanbase to latest iteration
+363 -36

0 comment

7 changed files

coetry

pr closed time in 25 days

PR opened zeit/integrations

Reviewers
update oceanbase to latest iteration
+363 -36

0 comment

7 changed files

pr created time in 25 days

create barnchzeit/integrations

branch : update/oceanbase

created branch time in 25 days

fork coetry/integrations

Example integrations for the ZEIT Now Integrations Platform

https://zeit.co/integrations

fork in 25 days

Pull request review commentzeit/now-examples

Add Next.js app wih a Node.js API powered by MongoDB, initial app

+const url = require('url')+const connect = require("../../lib/db");++module.exports = async (req, res) => {+  // Connect to MongoDB and get the client+  const client = await connect()++  // Parse queries or set defaults+  const { query } = url.parse(req.url, true);+  let limit = parseInt(query.limit) || 9+  let page = parseInt(query.page) || 1++  // If page query is less than one, default to 1+  if (page < 1) page = 1++  // If limit query is less than one or more than a hundred, default to either+  if (limit < 1) limit = 1+  if (limit > 100) limit = 100++  // Parse database name from MongoDB URI string+  const database = await client.db(url.parse(process.env.MONGODB_URI).pathname.substr(1))++  const signaturesCollection = await database.collection('signatures')++  const guestbook = await signaturesCollection.find().sort({ updated: -1 }).limit(limit).skip((page-1)*limit).toArray()++  // Get full count of profiles in collection and work out the number+  // of pages there will be, using the limit+  const signaturesCount = await signaturesCollection.countDocuments()+  const pageCount = Math.ceil(signaturesCount / limit);++  // Close the client connection+  await client.close()+

Add res.setHeader('cache-control', 's-maxage=1, max-age=0, stale-while-revalidate') here to unlock SPR for the DB responses.

timothyis

comment created time in a month

Pull request review commentzeit/now-examples

Add Next.js app wih a Node.js API powered by MongoDB, initial app

+// Dependencies+import { useEffect } from 'react'+import fetch from 'isomorphic-unfetch'+import { parseCookies, setCookie, destroyCookie } from 'nookies'+import Head from 'next/head'+import Link from 'next/link'+import { withRouter } from 'next/router'++// Components+import Signature from '../components/Signature'++HomePage.getInitialProps = async ctx => {+  const { req, query } = ctx+  const protocol = req+    ? `${req.headers['x-forwarded-proto']}:`+    : location.protocol+  const host = req ? req.headers['x-forwarded-host'] : location.host+  const baseURL = `${protocol}//${host}`+  const guestbookRequest = await fetch(+    `${baseURL}/api/guestbook?page=${query.page || 1}&limit=${query.limit || 5}`+  )+  const { guestbook, pageCount } = await guestbookRequest.json()+  const existing = guestbook.find(+    s => s.id === parseInt(query.id || parseCookies(ctx).id)+  )++  if (query.token === 'logout') {+    destroyCookie(ctx, 'token')+    destroyCookie(ctx, 'id')+    destroyCookie(ctx, 'name')+    return { baseURL, existing, guestbook }+  }++  if (query.id) {+    await setCookie(ctx, 'id', query.id, {+      maxAge: 30 * 24 * 60 * 60,+      path: '/'+    })+    await setCookie(ctx, 'login', query.login, {+      maxAge: 30 * 24 * 60 * 60,+      path: '/'+    })++    if (query.token && query.token !== 'logout') {+      await setCookie(ctx, 'token', query.token, {+        maxAge: 30 * 24 * 60 * 60,+        path: '/'+      })+    }++    const { id, login, token } = query+    return { baseURL, existing, guestbook, id, login, pageCount, token }+  }+  const { id, login, token } = await parseCookies(ctx)+  return { baseURL, existing, guestbook, id, login, pageCount, token }+}++function HomePage({+  baseURL,+  existing,+  guestbook,+  id,+  login,+  pageCount,+  token,+  router+}) {+  useEffect(() => {

I noticed here that you are not leveraging useState and are replacing the URL to force a refresh for updating the UI. The "react" way would be to keep track of state variables that trigger a re-render upon changing.

Docs on state hooks: https://reactjs.org/docs/hooks-state.html

timothyis

comment created time in a month

startedPavelDoGreat/WebGL-Fluid-Simulation

started time in a month

startedmathieudutour/timezone-butler

started time in a month

issue closedzeit/vrs

MongoDB connection sharing

👋Hi! Spent most of the yesterday figuring out how to properly connect to MongoDB Atlas from the serverless environment and overnight you are releasing this comprehensive store project! So I have a couple of specific questions.

  1. Have you considered sharing MongoDB connection between multiple invocations? It looks like MongoDB folks recommend declaring it as a global variable, so it may survive multiple invocations of a single lambda instance.

  2. They also mention that for performance it's critical to set callbackWaitsForEmptyEventLoop context's property to false which helps "avoiding closing the database connection". It's a AWS Lambda-specific setting, which tight to how AWS Lambda freezes processes. I believe otherwise AWS Lambda doesn't send the response to the user and waits till the connection is closed. This probably is not applicable to Now, since in Now we can directly write into HTTP response, rather than dealing with event callbacks, but still I would love if you could confirm and dispel any doubts?

closed time in a month

antonmoiseev

issue commentzeit/vrs

MongoDB connection sharing

The great thing about SPR (stale-while-revalidate) is that lambda responses are cached on our edge, so the database is not hit very frequently and reusing DB connections between invocations is not necessary 😌. The user is always served data from the cache, so ensuring that we have a fresh connection each time the cache is validated in the background is solid. Hope that clarifies! Will close this issue!

antonmoiseev

comment created time in a month

startedkkuchta/css-only-chat

started time in a month

startedethereumbook/ethereumbook

started time in a month

pull request commentzeit/vrs

Small fixes

thank you!

mtt87

comment created time in a month

push eventzeit/vrs

Mattia Asti

commit sha 155efd94c023bc8fed7c6466db5e92492b810385

Small fixes (#3)

view details

push time in a month

PR merged zeit/vrs

Small fixes

Thanks for the great tutorial and all the improvements you are making to Now!

I was reading the blog post and I noticed immediately that something was missing inside backend/api/get-products/index.js you are never returning docs (products)

So I checked the repo and found that the code was fine, it's just missing from the blog post so I'd suggest you to fix it.

Screenshot 2019-05-04 at 00 34 53

That said I noticed you are never returning in case of error so I made this PR to address that minor detail.

+4 -1

3 comments

3 changed files

mtt87

pr closed time in a month

PR opened tachyons-css/tachyons-styled-react

fix distDir property of now.json static-build config😅

It was originally set to build, but I had mistakenly changed it to public. This PR reverts that to the correct value and fixes the blank page currently on https://tachyons-styled-react.now.sh

+1 -1

0 comment

1 changed file

pr created time in a month

push eventcoetry/tachyons-styled-react

Allen Hai

commit sha 1238fe7f5926e6e768de593651a1a5b76288b2ac

fix distDir property of now.json static-build config😅

view details

push time in a month

push eventcoetry/tachyons-styled-react

Allen Hai

commit sha 0f4b916290558c29107c5b21af5a2fff219370c0

change build directory to 'public'

view details

push time in a month

PR opened tachyons-css/tachyons-styled-react

add build, alias, and route configs for now.json

If you have the Now GitHub integration properly configured with your repo, this PR will allow you to simply push and each push will trigger a new deployment with the proper production alias so you don't have to keep manually changing the project URL 😄

+33 -1

0 comment

2 changed files

pr created time in a month

push eventcoetry/tachyons-styled-react

Allen Hai

commit sha 849d85a0a2963325a1e09764122633d6593cff27

add build, alias, and route configs for now.json

view details

push time in a month

fork coetry/tachyons-styled-react

Tachyons implemented with emotion and styled-system. Sits on create-react-app.

https://tachyons-styled-react-eprwusuqnz.now.sh

fork in a month

startedMichaelBurge/pyramid-scheme

started time in a month

startedzeit/vrs

started time in a month

startedmhashim6/Open-Hadith-Data

started time in a month

push eventzeit/vrs

Allen Hai

commit sha 9b0273c4136c017b45450935132849fbbb69017d

remove email from User

view details

push time in a month

push eventzeit/vrs

Allen Hai

commit sha a1a90df4cd4fe58959925a6927f6b7f5e216b1a8

remove email requirement from User schema

view details

push time in a month

push eventzeit/vrs

Allen Hai

commit sha 51cb89528b42f041b5d256406fb2a12c78811866

remove email from passport-github strategy

view details

push time in a month

push eventzeit/vrs

Allen Hai

commit sha 2e697648debf8f9b2229c882a96da814395a9406

clear cart after paying

view details

push time in a month

startedglittergallery/GlitterGallery

started time in a month

push eventzeit/vrs

Allen Hai

commit sha cdb9ffe698ebf18cce3d0ae83a21b2bd228b465d

use window.top to determine iframe and open login in new tab if so

view details

push time in a month

push eventzeit/vrs

Allen Hai

commit sha 5177b455e6daa9dee77986e1ea8e7be417b24576

parase iframe query param from model page and disable stuff accordingly

view details

push time in a month

push eventzeit/vrs

Allen Hai

commit sha 29e9c909cc9c270114e4fe78fba9009ce16e0f84

hide login if URL is on zeit

view details

push time in a month

startedvadimdemedes/pastel

started time in a month

startedmoollaza/repo-remover

started time in 2 months

create barnchcoetry/netlify-artisan-static

branch : master

created branch time in 2 months

created repositorycoetry/netlify-artisan-static

created time in 2 months

startedtaylorconor/quinesnake

started time in 2 months

startedpopeindustries/lit-html-server

started time in 2 months

startednamin/scheme-mechanics

started time in 2 months

startedmxstbr/micro-github

started time in 2 months

startedstackgl/webgl-workshop

started time in 2 months

startedTimoSta/sprite

started time in 2 months

startedcallumflack/the-littoral-line

started time in 2 months

startedzeit/fun

started time in 2 months

startedalpacaaa/zero-bullshit-haskell

started time in 2 months

PR opened actions/zeit-now

fix casing of Zeit -> ZEIT to stay on-brand

This is a common mistake made by many 😄 , but ZEIT should be in all caps! If you could change that in the repo description, that would be great as well!

+2 -2

0 comment

1 changed file

pr created time in 2 months

push eventcoetry/zeit-now

Allen Hai

commit sha d38911a39ec0bb088ad25b7b2431084c64f832fc

fix casing of Zeit -> ZEIT to stay on-brand

view details

push time in 2 months

fork coetry/zeit-now

GitHub Action for interacting with Zeit Now

fork in 2 months

startedPolymer/lit-html

started time in 2 months

startedwasmerio/wasmer

started time in 2 months

startedcodebytere/codebytere.github.io

started time in 2 months

push eventcoetry/intro-to-three

Allen Hai

commit sha 2317f74e830c4bff0ae84aadafe6a554a6735704

fix source path for images

view details

push time in 2 months

push eventcoetry/intro-to-three

Allen Hai

commit sha 1fb91c0242aca0f53e6eecf063be4384eb5f3882

fix html-minifier builder typo

view details

push time in 2 months

push eventcoetry/intro-to-three

Allen Hai

commit sha a7b4c4ddc1dc946c0b1d78ba0976a4e7c255d3f2

add now.json

view details

push time in 2 months

create barnchcoetry/intro-to-three

branch : master

created branch time in 2 months

created repositorycoetry/intro-to-three

hacking around with three.js

created time in 2 months

startedjonatasbaldin/fin

started time in 2 months

create barnchcoetry/next-express-monorepo

branch : master

created branch time in 2 months

created repositorycoetry/next-express-monorepo

created time in 2 months

startedcarp-lang/Carp

started time in 2 months

startedAutomattic/mongoose

started time in 2 months

startedrswier/c4

started time in 2 months

startedrabite0/hunter

started time in 2 months

push eventcoetry/serverless-todo

Allen Hai

commit sha be7254f0bdd600b3648546424d20499c493d1924

modify anchor tag styles

view details

push time in 2 months

push eventcoetry/serverless-todo

Allen Hai

commit sha 9488de5aad498e3e8dfd0bfdb6ad3cd1f6834a9f

change header color to red

view details

push time in 2 months

push eventcoetry/serverless-todo

Allen Hai

commit sha 60dd312db69a4b8c7d8421b04b185642b0e9277d

initial commit

view details

push time in 2 months

create barnchcoetry/serverless-todo

branch : master

created branch time in 2 months

created repositorycoetry/serverless-todo

created time in 2 months

push eventcoetry/serverless-todo

Allen Hai

commit sha 53b0b4cd01efe2408be1ec95b1f5634d57386037

initial commit

view details

push time in 2 months

create barnchcoetry/serverless-todo

branch : master

created branch time in 2 months

created repositorycoetry/serverless-todo

created time in 2 months

startedxyproto/algernon

started time in 2 months

startedsahat/hackathon-starter

started time in 2 months

startedneoclide/coc.nvim

started time in 3 months

startedfastly/lucet

started time in 3 months

issue commentzeit/ncc

@now/node error: Cannot find module 'pug'

I agree, solving this for all express template engines would be ideal.

coetry

comment created time in 3 months

issue openedzeit/ncc

@now/node error: Cannot find module 'pug'

When using the stable or canary builder, express deployments that depend on pug will run into the following error: Error: Cannot find module 'pug'

To reproduce this issue, I made a repo that you can clone and deploy: https://github.com/coetry/wtf-pug

Note that i've included a test-server.js file, which works fine locally. Also note that this is not an ncc error because if you run ncc build index.js && cp test-server.js dist && cd dist && node test-server.js, it will work as expected. This error is only encountered when deploying.

created time in 3 months

issue openedzeit/now-builders

@now/node error: Cannot find module 'pug'

When using the stable or canary builder, express deployments that depend on pug will run into the following error: Error: Cannot find module 'pug'

To reproduce this issue, I made a repo that you can clone and deploy: https://github.com/coetry/wtf-pug

Note that i've included a test-server.js file, which works fine locally. Also note that this is not an ncc error because if you run ncc build index.js && cp test-server.js dist && cd dist && node test-server.js, it will work as expected. This error is only encountered when deploying.

created time in 3 months

push eventcoetry/wtf-pug

Allen Hai

commit sha e57b7ac47107068bec2ecffc9a4250202e462ccb

change node builder to stable

view details

push time in 3 months

more