GithubHelp home page GithubHelp logo

andrewmruddy / workerd-docker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pmbanugo/workerd-docker

0.0 0.0 0.0 14 KB

License: Apache License 2.0

TypeScript 64.66% Cap'n Proto 23.98% Dockerfile 11.36%

workerd-docker's Introduction

workerd-docker

A simple URL shortener implemented using Workers (workerd) running in Docker/Kubernetes.

See this blog post for some details.

Forked and modifed sample from https://github.com/WalshyDev/workerd-example

Running

To run simply install the dependencies and run workerd :)

Requests are served at http://localhost:8080 (can be changed in config.capnp). Update UPSTASH_REDIS_REST_TOKEN and UPSTASH_REDIS_REST_URL to your Upstash redis details, or to any Redis server credentials with a different provider.

# Install the dependencies (including workerd)
npm i

# Bundle your Worker and start Workerd serving the Worker
npm run dev

Building Docker Image

npm run build

docker build . -t redirect

# Run the image
docker run -d --rm -p 49160:8080 redirect

Testing

Once the Worker is running we can test it!

To create a redirect do a POST to /create like so:

$ curl -X POST -d '{"slug": "test", "destination": "https://pmbanugo.me"}' http://localhost:8080/create

Then to test the redirect simply send a GET request to the slug like so:

$ curl -i http://localhost:8080/test
HTTP/1.1 302 Found
Content-Length: 0
Location: https://pmbanugo.dev

workerd-docker's People

Contributors

pmbanugo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.