Code Monkey home page Code Monkey logo

isomorphic-ts's Introduction

libSQL by Turso

libSQL

libSQL is an open source, open contribution fork of SQLite, created and maintained by Turso.

libSQL Docs · libSQL Manifesto · Turso · Turso Docs · Discord · Blog & Tutorials

MIT discord activity phorm.ai


Documentation

We aim to evolve it to suit many more use cases than SQLite was originally designed for, and plan to use third-party OSS code wherever it makes sense.

libSQL has many great features, including:

  • Embedded replicas that allow you to have replicated database inside your app.
  • libSQL server for remote SQLite access, similar to PostgreSQL or MySQL
  • Supports Rust, JavaScript, Python, Go, and more.

There are also various improvements and extensions to the core SQLite:

The comprehensive description can be found here

Official Drivers

Experimental Drivers

  • Python (experimental)
  • C (experimental)

Community Drivers

  • PHP
  • D (experimental, based on the C driver)

GUI Support

Getting Started

The project provides two interfaces: the libSQL API, which supports all the features, and the SQLite C API for compatibility.

To build the SQLite-compatible C library and tools, run:

cargo xtask build

To run the SQL shell, launch the libsql program:

$ cd libsql-sqlite3 && ./libsql
libSQL version 0.2.1 (based on SQLite version 3.43.0) 2023-05-23 11:47:56
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
libsql>

Docker

To run libSQL using docker, refer to the Docker Docs

Why a fork?

SQLite has solidified its place in modern technology stacks, embedded in nearly any computing device you can think of. Its open source nature and public domain availability make it a popular choice for modification to meet specific use cases.

But despite having its code available, SQLite famously doesn't accept external contributors and doesn't adhere to a code of conduct. So community improvements cannot be widely enjoyed.

There have been other forks in the past, but they all focus on a specific technical difference. We aim to be a community where people can contribute from many different angles and motivations.

We want to see a world where everyone can benefit from all of the great ideas and hard work that the SQLite community contributes back to the codebase. Community contributions work well, because we’ve done it before. If this was possible, what do you think SQLite could become?

You can read more about our goals and motivation in our product vision.

Compatibility with SQLite

Compatibility with SQLite is of great importance for us. But it can mean many things. So here's our stance:

  • The file format: libSQL will always be able to ingest and write the SQLite file format. We would love to add extensions like encryption, and CRC that require the file to be changed. But we commit to always doing so in a way that generates standard sqlite files if those features are not used.
  • The API: libSQL will keep 100% compatibility with the SQLite API, but we may add additional APIs.
  • Embedded: SQLite is an embedded database that can be consumed as a single .c file with its accompanying header. libSQL will always be embeddable, meaning it runs inside your process without needing a network connection. But we may change the distribution, so that object files are generated, instead of a single .c file.

License

libSQL is licensed under an Open Source License, and we adhere to a clear Code of Conduct.

isomorphic-ts's People

Contributors

athoscouto avatar honzasp avatar huozhi avatar matthewp avatar penberg avatar remiboudreau avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

isomorphic-ts's Issues

Switch to Node 18 fetch()

The node-fetch package is now ESM-only, which makes it hard to use for @libsql/client, which also compiles to CommonJS. Let's consider switching to Node 18 and using it's fetch() instead.

Incorrect imports for esm assets

in isomorphic-fetch/node.mjs it's destruction fetch function from node-fetch (v2.6.x) to get other exports like Request

import fetch from "node-fetch";
const { Request, Response, Headers } = fetch;
export { fetch, Request, Response, Headers };

The esm version of node-fetch 2.6.x doesn't contain those exports on fetch function. Need to chanage to import/export destruction expression to get them

asset: https://unpkg.com/browse/[email protected]/lib/index.mjs

fetch.isRedirect = function (code) {
	return code === 301 || code === 302 || code === 303 || code === 307 || code === 308;
};

// expose Promise
fetch.Promise = global.Promise;

export default fetch;
export { Headers, Request, Response, FetchError };
- import fetch from "node-fetch";
- const { Request, Response, Headers } = fetch;
- export { fetch, Request, Response, Headers };
+ export { default as fetch, Request, Response, Headers } from 'node-fetch'

Related issue on next.js: vercel/next.js#51309

punycode DeprecationWarning

node-fetch is causing deprecation warnings in node 21

(node:1249861) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.

TypeError: Invalid URL caused by mismatch in fetch()

Describe the issue

Using Remix 2.9.2 with any version of libsql/client >= 0.6.0 results in the following error:

node:internal/url:814
    const href = bindingUrl.parse(input, base, raiseException);
                            ^

TypeError: Invalid URL
    at new URL (node:internal/url:814:29)
    at new Request (/home/ali/Desktop/remix-template-starter/node_modules/@remix-run/web-fetch/dist/lib.node.cjs:1437:16)
    at /home/ali/Desktop/remix-template-starter/node_modules/@remix-run/web-fetch/dist/lib.node.cjs:1732:19
    at new Promise (<anonymous>)
    at fetch (/home/ali/Desktop/remix-template-starter/node_modules/@remix-run/web-fetch/dist/lib.node.cjs:1729:9)
    at fetchWithAgentSelection (file:///home/ali/Desktop/remix-template-starter/node_modules/@libsql/isomorphic-fetch/node.js:19:12)
    at #flush (file:///home/ali/Desktop/remix-template-starter/node_modules/@libsql/hrana-client/lib-esm/http/stream.js:245:23)
    at #flushPipeline (file:///home/ali/Desktop/remix-template-starter/node_modules/@libsql/hrana-client/lib-esm/http/stream.js:233:20)
    at #flushQueue (file:///home/ali/Desktop/remix-template-starter/node_modules/@libsql/hrana-client/lib-esm/http/stream.js:223:32)
    at file:///home/ali/Desktop/remix-template-starter/node_modules/@libsql/hrana-client/lib-esm/http/stream.js:181:50 {
  code: 'ERR_INVALID_URL',
  input: '[object Request]'
}

Downgrading to libsql/client 0.5.6 fixes the issue, as discovered by the following issues:
tursodatabase/libsql-client-ts#204
prisma/prisma#23774

However, after investigating, I've noticed that the issue isn't due to using a version of libsql/client >= 0.6.0, as I was able to use 0.6.2 with the condition that I downgrade libsql/isomorphic-fetch to 0.1.12 which is a dependency of @libsql/hrana-client which is a dependency of libsql/client. I've then started looking at the changes between libsql/isomorphic-fetch 0.1.12 and 0.2.0, which is just this 1 commit thankfully: 218800b

And what I've noticed is that now, we are passing the entire Request object as the first argument to the fetch function, going back at the error mentioned above, specifically this one here:

at fetch (/home/ali/Desktop/remix-template-starter/node_modules/@remix-run/web-fetch/dist/lib.node.cjs:1729:9)

What is happening here is that the fetch function from @remix-run/web-fetch, tries to treat it as a string URL, leading to the ERR INVALID URL error, because we are trying to pass it the entire Request object:

 input: '[object Request]'

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.