Skip to content
destinydinamPublic

About

A simple app to help you share code

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

CodeShare

A simple, fast, and secure code sharing platform. Share your code snippets and files instantly with a permanent URL.

Features

  • No Accounts Required: Just upload and share
  • Universal Access: Works with any text editor or IDE
  • CLI-Friendly: Use curl to upload and download files
  • Permanent Storage: No expiration, no cleanup required
  • Private Files: Optional access codes for sensitive code
  • Syntax Highlighting: Automatic language detection and highlighting
  • File Type Support: Supports all major programming languages

Tech Stack

  • Frontend: Next.js 15 with App Router, TypeScript, Tailwind CSS
  • Backend: PostgreSQL with Drizzle ORM, Oslo for auth
  • File Storage: Direct database storage
  • CLI Access: curl for universal file operations

Quick Start

Prerequisites

  • Node.js 18+ and pnpm
  • PostgreSQL database

Installation

  1. Clone the repository:
git clone https://github.com/destinydinam/codeshare.git
cd codeshare
  1. Install dependencies:
pnpm install
  1. Set up environment variables:
cp env.example .env

Edit .env with your database URL:

DATABASE_URL="postgresql://username:password@localhost:5432/codeshare"
NEXT_PUBLIC_APP_URL="http://localhost:3000"
  1. Set up the database:
pnpm db:push
  1. Start the development server:
pnpm dev

Visit http://localhost:3000 to see the app.

API Reference

Upload File

POST /api/upload

Form Data:

  • file (optional): File to upload
  • content (optional): Direct content
  • filename (required if content): Filename for content
  • accessCode (optional): Access code to make file private

Download File

GET /api/files/[id]/download
POST /api/files/[id]/download

View File

GET /api/files/[id]?accessCode=code

Delete File

DELETE /api/files/[id]

Curl Download

POST /api/files/[id]/curl

Usage Examples

Upload a file via curl

curl -X POST $APP_URL/api/upload \
  -F "file=@example.js"

Upload content directly

curl -X POST $APP_URL/api/upload \
  -F "content=console.log('Hello World')" \
  -F "filename=hello.js"

Upload private file

curl -X POST $APP_URL/api/upload \
  -F "file=@example.js" \
  -F "accessCode=secret123"

Upload private content

curl -X POST $APP_URL/api/upload \
  -F "content=console.log('Hello World')" \
  -F "filename=hello.js" \
  -F "accessCode=secret123"

Download a file

curl -X GET $APP_URL/api/files/[file-id]/download

Download private file

curl -X POST $APP_URL/api/files/[file-id]/download \
  -F "accessCode=secret123"

Download to specific path

curl -X GET $APP_URL/api/files/[file-id]/download -o "/path/to/folder/filename.js"

File Types Supported

CodeShare supports a wide range of file types:

  • JavaScript/TypeScript: .js, .jsx, .ts, .tsx
  • Python: .py, .pyw, .pyi
  • Java: .java
  • C/C++: .c, .cpp, .cc, .cxx, .h, .hpp
  • C#: .cs
  • Go: .go
  • Rust: .rs
  • PHP: .php
  • Ruby: .rb
  • Swift: .swift
  • Kotlin: .kt, .kts
  • Scala: .scala, .sc
  • HTML/CSS: .html, .css, .scss, .sass, .less
  • Markup: .xml, .json, .yaml, .yml, .toml
  • Shell: .sh, .bash, .zsh, .fish, .ps1
  • SQL: .sql
  • R: .r
  • MATLAB: .m
  • Lua: .lua
  • Perl: .pl, .pm
  • Haskell: .hs, .lhs
  • Erlang: .erl, .hrl
  • Elixir: .ex, .exs
  • Clojure: .clj, .cljs
  • F#: .fs, .fsx
  • Dart: .dart
  • Assembly: .asm, .s
  • Documentation: .md, .txt, .log

Development

Database

# Generate migration
pnpm db:generate

# Push schema changes
pnpm db:push

# Open database studio
pnpm db:studio

Code Quality

# Lint code
pnpm lint

# Type check
pnpm build

Deployment

Vercel

  1. Connect your GitHub repository to Vercel
  2. Set environment variables in Vercel dashboard
  3. Deploy automatically on push to main branch

Railway

  1. Connect your GitHub repository to Railway
  2. Add PostgreSQL service
  3. Set environment variables
  4. Deploy automatically

Self-Hosted

  1. Set up PostgreSQL database
  2. Configure environment variables
  3. Build and run with Docker or directly

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

MIT License - see LICENSE for details.

Author

Built with ❤️ by Destiny Dinam

About

A simple app to help you share code

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages