Skip to content

The server repository for Tiny API - A website for developers to quickly create REST endpoints with a static JSON response for testing and development

License

Notifications You must be signed in to change notification settings

cameronhh/tiny-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This project is no longer active.

Tiny API - A Tiny API To Make Tiny APIs

Website Preview

  • Quickly prototyping some front-end code and need a couple of endpoints to return some static JSON?
  • Perhaps you're integrating a front-end with a back-end that doesn't have a test server?
  • Maybe, you just want to see a website with a memorable user experience?
  • Make an endpoint that returns static JSON in seconds with Tiny API

This repo is the server behind https://tiny-api.dev. The Tiny API Server is a REST API written in Go using Gin.

The code for the front end can be found here.

Setting up the development environment

1. Start a development database

Tiny API is built on top of Postgres (I know, SQLite would have been tinier). You can quickly run a test database with docker using the following command.

docker run -d -p 5432:5432 \
--name tiny-api-postgres \
-e POSTGRES_USER=dev \
-e POSTGRES_PASSWORD=mysecretpassword \
-e POSTGRES_DB=tiny-api-dev \
postgres

2. Set Environment Variables

Running the server requires the following environment variables to be set:

DB_CONNECTION=postgresql://dev:mysecretpassword@localhost:5432/tiny-api-dev?sslmode=disable
PORT=8080
GIN_ENV=development
CLIENT_URL=http://localhost:3000

To simplify things, create a .env and then run:

export $(cat .env | xargs)

3. Run the tests

Running the tests will populate the test database with tables if they don't already exist. The tests can be run with:

go test

4. Run the server

To run the server, run:

go run .

Things To Do:

  • Allow only URL safe characters to be used for temp endpoints
  • Add an endpoint to check if a new temp endpoint already exists or not
  • Remove (or at least comment out) endpoints that are unused
  • Improve the directory structure (tests in particular)
  • Write a database script for bootstrapping the tables
  • Add an expiry for temp endpoints, and a helpful response message once those endpoints are hit after expiring

About

The server repository for Tiny API - A website for developers to quickly create REST endpoints with a static JSON response for testing and development

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages