Skip to content

Latest commit

ย 

History

26 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿšฉ learning journey

๐Ÿ“ Initial Data & DBMS

  • use vercel-postgres

    make dummy data
      ```sql
      SELECT version();
      PostgreSQL 15.10 on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
      -- https://hub.docker.com/layers/library/postgres/15.10/images/sha256-6bd528fd9ed2ca50c0dd7c85c1bc20d0150c63418a04d8d3973cab95f63f9567
    
      -- CREATE TABLE => postgres_init/1-create-table.sql
    
      \d+ flags
    
    
      INSERT INTO flags (name, latitude, longitude, img_url) VALUES
      ('#BRAT impeachment and itโ€™s completely different but also still impeachment', 
      37.525307 + (37.530139 - 37.525307) * RANDOM(), 
      126.919467 + (126.922896 - 126.919467) * RANDOM(), 
      '/dummy/d1.webp')
    
      INSERT INTO flags (name, latitude, longitude, img_url) VALUES
      ('#BRAT impeachment and itโ€™s completely different but also still impeachment', 37.525307 + (37.530139 - 37.525307) * RANDOM(), 126.919467 + (126.922896 - 126.919467) * RANDOM(), '/dummy/d1.webp'),
      ('Korean branch of the Jedi Federation', 37.525307 + (37.530139 - 37.525307) * RANDOM(), 126.919467 + (126.922896 - 126.919467) * RANDOM(), '/dummy/d2.webp'),
      ('Rapping Rabbit Federation', 37.525307 + (37.530139 - 37.525307) * RANDOM(), 126.919467 + (126.922896 - 126.919467) * RANDOM(), '/dummy/d3.webp'),
      ('National Carrot Alliance Loving Rabbits', 37.525307 + (37.530139 - 37.525307) * RANDOM(), 126.919467 + (126.922896 - 126.919467) * RANDOM(), '/dummy/d4.webp'),
      ('Flags World Championship', 37.525307 + (37.530139 - 37.525307) * RANDOM(), 126.919467 + (126.922896 - 126.919467) * RANDOM(), '/dummy/FWC.png');
    
    
      SELECT id,name,img_url FROM flags ORDER BY id DESC;
    
      SELECT
          id,
          flag_id,
          delta_cnt,
          created_at AT TIME ZONE 'Asia/Seoul' AS created_at_kst
      FROM 
          flag_like_history
      ORDER BY 
          id DESC;
    
      SHOW TIME ZONE; -- GMT
    
      SELECT CURRENT_TIMESTAMP;
    
      -- ์ชผ์ธ
      SELECT 
          f.id,
          f.name,
          f.img_url,
          COALESCE(SUM(fl.delta_cnt), 0) AS like_count
      FROM 
          flags f
      LEFT JOIN 
          flag_like_history fl
      ON 
          f.id = fl.flag_id
      GROUP BY 
          f.id, f.name, f.img_url
      ORDER BY 
          f.id DESC
      ```
    
  • Alternatively, you can use the local DBMS using the Dockerizing part below. The setting file DATABASE_CLIENT needs to be changed.

๐ŸŒฑ Env

  • Rename env.dummy to .env.local. Make sure the file is not pushed to the public GitHub repository.
  • To avoid using analytics and statistics by connecting to Google Firebase, delete analytics.ts.
  • Refer to the Vercel CLI to sync variables for database connection.
  • I used https://api.imgbb.com/ for image uploads. In your case, you should obtain a new API key

๐Ÿ’ป Local Run

  • ested on WSL Ubuntu 22.04.4 LTS and macOS. ( node : v20.17.0 || v22.12.0, nextjs : 14.2.19)
$ npm install
$ npm run dev

Dev Python

$ pyenv global
3.10.12
# $ python -m venv venv
$ source venv/bin/activate
# $pip install -r requirements.txt
$ uvicorn api.index:app --reload

Test

$ npx jest -t "should correctly join URL parts into a complete URL"
 PASS  __tests__/utils.test.ts (5.773 s)
-----------------|---------|----------|---------|---------|----------------------------------------------------
File             | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                                  
-----------------|---------|----------|---------|---------|----------------------------------------------------
All files        |   22.42 |      100 |    9.09 |   22.42 |                                                    
 app/lib         |   54.54 |      100 |       0 |   54.54 |                                                    
  getClientId.ts |   54.54 |      100 |       0 |   54.54 | 7-11                                               
 lib             |   18.75 |      100 |      10 |   18.75 |                                                    
  utils.ts       |   18.75 |      100 |      10 |   18.75 | 5-7,9-16,18-23,25-27,29-40,44-72,74-82,84-87,89-92 
-----------------|---------|----------|---------|---------|----------------------------------------------------

Test Suites: 1 skipped, 1 passed, 1 of 2 total
Tests:       3 skipped, 1 passed, 4 total
Snapshots:   0 total
Time:        6.379 s, estimated 10 s
Ran all test suites with tests matching "should correctly join URL parts into a complete URL"

$ npm test

๐Ÿค Contribution

  • Contributions are open, though I donโ€™t expect anyone to take an interest. Iโ€™ll gratefully accept any small advice or help. Thank you. Best regards. ๐Ÿ˜Š๐Ÿ‘

๐Ÿš€ Deploy & Connect DB

โš“ Dockerizing

  • The .env.local file DATABASE_CLIENT needs to be changed.
    # docker compose down --volumes --remove-orphans
    # sudo rm -rf postgres_data
    
    $ docker compose up -d db adminer
    $ docker compose build web
    $ docker compose up -d web

๐Ÿ”– Ref

Errors

  • Application error: a client-side exception has occurred (see the browser console for more information).
  • Error: Cannot find module '/home/ppabam/code/flag123/node_modules/.pnpm/bcrypt@5.1.1/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node'
    $ npm rebuild bcrypt
  • Clear Cache and Rebuild
    $ rm -rf node_modules package-lock.json .next
    $ npm install
    $ npm run build

About

Tracking the progress of my learning journey with topics such as Vim and Pandas 10-minute guide. / ๐Ÿด forked from dMario24/flag123

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages