dolphins7.skeleton/server/lib/twenty/server.rb
0x1eef 2e8cf6e333 Drop 'twenty-' prefix from toplevel directories
The directories twenty-{server,client,cli} have been renamed to
not include 'twenty-'. The gems are still published with the twenty-
prefix, otherwise a collision is impossible to avoid. This commit makes
it slightly easier to generalize twenty.
2024-04-21 20:11:25 -03:00

37 lines
776 B
Ruby

# frozen_string_literal: true
module Twenty
require "fileutils"
require "sequel"
require_relative "server/path"
##
# @return [String]
# Returns the location of the default SQLite database.
def self.default_database
@default_database ||= File.join(Path.datadir, "database.sqlite")
end
##
# Establishes a database connection.
#
# @param [String] path
# The path to a SQLite3 database file.
#
# @return [void]
def self.establish_connection(path:)
@connection = Sequel.connect(
adapter: "sqlite",
database: path
)
end
def self.connection
establish_connection unless @connection
@connection
end
FileUtils.touch(default_database)
require_relative "server/graphql"
require_relative "server/rack"
end