Coder Social home page Coder Social logo

codingdoug / app-find-me-on Goto Github PK

View Code? Open in Web Editor NEW

This project forked from turso-extended/app-find-me-on

0.0 0.0 0.0 243 KB

A social links listing app built with Qwik and Turso

Home Page: https://findmeon.netlify.app

License: MIT License

JavaScript 6.08% TypeScript 89.22% CSS 4.70%

app-find-me-on's Introduction

FindMeOn ⚡️

A social links listing app built with [Qwik] and Turso.

Technologies used


Project Structure

This project is using Qwik with QwikCity. QwikCity is just a extra set of tools on top of Qwik to make it easier to build a full site, including directory-based routing, layouts, and more.

Inside your project, you'll see the following directory structure:

├── public/
│   └── ...
└── src/
    ├── components/
    │   └── ...
    └── routes/
        └── ...
  • src/routes: Provides the directory based routing, which can include a hierarchy of layout.tsx layout files, and an index.tsx file as the page. Additionally, index.ts files are endpoints. Please see the routing docs for more info.

  • src/components: Recommended directory for components.

  • public: Any static assets, like images, can be placed in the public directory. Please see the Vite public directory for more info.

Add Integrations and deployment

Use the pnpm qwik add command to add additional integrations. Some examples of integrations include: Cloudflare, Netlify or Express server, and the Static Site Generator (SSG).

pnpm qwik add # or `yarn qwik add`

Setting up the database

Install the Turso CLI.


Create a new turso database.

```sh
turso db create [DATABASE-NAME]

Access the database through the Turso CLI shell.

turso db shell [DATABASE-NAME]

Create tables and indexes

Here is the schema for the users table that we should create.

create table users(
	id integer primary key,
	email varchar(255) not null,
	full_name varchar(100) not null,
	username varchar(50) not null,
	created_at integer default (cast(unixepoch() as int))
);

And, the links table’s sql is as follows.

create table links(
	id integer primary key,
	user_id integer not null,
	website varchar(100) not null,
	link text not null,
	created_at integer default (cast(unixepoch() as int)),

	foreign key(user_id) references users(id)
);

For fast data retrieval, accompanying indexes should also be set up for the two tables.

For the users table we need the username to be both a unique and an indexed column, since we do not want users to have identical usernames and because we'll be querying the table using this column as a filter repeatedly. The email column should also be a unique index as we do not want users to have identical emails.

So create unique indexes of these two colums as follows.

-- unique index for the email column
create unique index idx_users_email on users(email);

-- unique index for the username column
create unique index idx_users_username on users(username);

Likewise, for the links table, we do not want users to have duplicate social links, so we are going to create a multicolumn unique index for the user_id and link columns.

create unique index idx_links_userid_link on links(user_id, link);

Set up Turso on the project

To access the data stored inside your database, you need the Turso database url and an authentication token.

To obtain the database url, run the following command:

turso db show [DATABASE-NAME] --url

And, to create an authentication token for your database, run:

turso db tokens create [DATABASE-NAME] --expiration none

Add a .env file at the root of the project and inside it add the values obtained above as the database url and authentication token for your Turso database.

VITE_TURSO_DB_URL=
VITE_TURSO_DB_AUTH_TOKEN=

app-find-me-on's People

Contributors

xinnks 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.