Skip to content

Commit

Permalink
Project Cleanup (#8)
Browse files Browse the repository at this point in the history
* update readme, seeding works

* updated readme

* updated readme
  • Loading branch information
saddiqs1 authored Jan 19, 2024
1 parent 2ae8017 commit f121feb
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 18 deletions.
67 changes: 54 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,53 @@
This is a basic [Next.js](https://nextjs.org/) template with [Mantine Core & Notifications](https://mantine.dev/) setup.
# CS Crosshair Site

[![Deploy](https://github.com/saddiqs1/cs-crosshairs/actions/workflows/main-deploy.yml/badge.svg)](https://github.com/saddiqs1/cs-crosshairs/actions/workflows/main-deploy.yml)

Back in the good old days of CS:GO, we had the `apply_crosshair_code CSGO-...` command to allow us to quickly switch crosshairs. With the launch of CS2, this was removed, with no mention as to whether it would be returned or not. So in the meantime, you can use this site to enter in a crosshair code and copy all the crosshair commands to your clipboard to allow you to be able to switch crosshair using the in game console.
![Preview 1](preview-1.png)

You can also store crosshairs on the site, to allow you to be able to switch quickly between preferred crosshairs on the fly mid game.
![Preview 2](preview-2.png)

## Tech Stack / Main Packages Used

- [NextJs](https://nextjs.org/) with [Typescript](https://www.typescriptlang.org/)
- [SWR](https://swr.vercel.app/)
- [Iron Session](https://github.com/vvo/iron-session)
- [Mantine Component Library (v6)](https://v6.mantine.dev/pages/getting-started/)
- [Kysely](https://kysely.dev/) with [kysely-codegen](https://github.com/RobinBlomberg/kysely-codegen)
- [Postgres](https://www.postgresql.org/)

## Prerequisites

You will need to install the following in order to build, run and develop this repo locally:

- [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
- [Node & `npm`](https://nodejs.org/en/download)
- Alternatively you can download both of these via [`nvm`](https://github.com/nvm-sh/nvm#installing-and-updating)
- [Postgres](https://www.postgresql.org/download/)

## Getting Started

1. Run the development server:
1. Create a file at the root level called `.env.local`, following the `.env example` file. Fill in the relevant gaps.

2. Install all packages.

```bash
npm run dev
npm i
```

2. Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
3. Run the `migrate` command to initialise your database, and optionally run the `db:seed` command to seed your database with example data to start off with.

```bash
npm run migrate
npm run db:seed
```

4. Run the development server and view the page in your browser at [http://localhost:3000](http://localhost:3000).

```bash
npm run dev
```

## Database Commands

Expand All @@ -24,7 +63,7 @@ This is a basic [Next.js](https://nextjs.org/) template with [Mantine Core & Not
npm run migrate
```

- Generate your database types. You should run this everytime after you have run a new migration.
- Generate your database types. You should run this every time after you have run a new migration.

```bash
npm run db:generate
Expand Down Expand Up @@ -60,13 +99,15 @@ This is a basic [Next.js](https://nextjs.org/) template with [Mantine Core & Not
npm run dev:reset-db
```

### TODO
## Contribution Guide

For simplicity's sake, we are using the [`issues`](https://github.com/saddiqs1/cs-crosshairs/issues) tab as a way to track tasks that need doing. Feel free to pick up anything from this list and contribute in any way possible!
The major design philosophy to keep in mind when developing anything on this site is to **keep the site as lightweight and as performant as possible**. Ideally players will be using this site whilst playing CS at the same time, and every frame matters whilst playing, so whenever possible avoid anything overly resource intensive e.g. over the top animations.
## Contact Me
- [ ] Fix `csgo-sharecode` package import
- [ ] Show crosshair style within preview
- [ ] toggle between 16:9 vs 4:3 for crosshair preview
- [ ] allow user to save crosshair
- [ ] validation on converter page
If you need any help/want to ask any questions, feel free to reach out to me in any of the following ways:
- [ ] create login
- [ ] create ui for entering in and saving crosshairs
- Twitter: [@shoobie_cs](https://twitter.com/shoobie_cs)
- Discord: shoobie96
54 changes: 49 additions & 5 deletions database/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,65 @@ import chalk from 'chalk'
import { getDb, getEnv } from './utils'
import { Kysely } from 'kysely'
import { DB } from './database'
import { createInterface } from 'readline'

async function main(db: Kysely<DB>) {
console.log(chalk.gray(`Seeding currently unimplemented...`))
console.log(chalk.blue(`Started Seeding...\n`))

/*
TODO: Implement below. Take developer prompt to create a user, with either preset crosshair options or allow them to enter in some.
const rl = createInterface({
input: process.stdin,
output: process.stdout,
})

const askQuestion = (query: string): Promise<string> => {
return new Promise((resolve) =>
rl.question(chalk.magenta(`> ${query}`), resolve)
)
}

const steamId64 = await askQuestion('Enter steamid64 value of user: ')
const insertCrosshairs = await askQuestion(
'Do you want to enter example crosshairs? (y/n): '
)

console.log(chalk.blue(`Starting Seed...`))
rl.close()

await db.transaction().execute(async (trx) => {
// Any seeding happens here.
await db
.insertInto('users')
.values({ id: 1, steam_uid: steamId64 })
.executeTakeFirstOrThrow()
console.log(chalk.greenBright(`\nUser ${steamId64} added.`))

if (insertCrosshairs.toLowerCase() === 'y') {
const user = await db
.selectFrom('users')
.select('id')
.where('steam_uid', '=', steamId64)
.executeTakeFirstOrThrow()

await db
.insertInto('crosshairs')
.values([
{
user_id: user.id,
name: 'Blue Small',
crosshair: 'CSGO-9r8iB-9WwzR-tndTZ-oQo6P-nysyM',
},
{
user_id: user.id,
name: 'Yellow Thick',
crosshair: 'CSGO-5fKKR-Eab4o-viAxH-Xvx38-T3SKF',
},
])
.execute()

console.log(chalk.greenBright(`Crosshairs added.\n`))
}
})

console.log(chalk.greenBright(`Finished Seeding!`))
*/
}

const env = getEnv()
Expand Down
Binary file added preview-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added preview-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f121feb

Please sign in to comment.