dolphins7.skeleton/server/lib/twenty/server.rb

70 lines
1.4 KiB
Ruby
Raw Normal View History

2023-12-08 17:28:45 +01:00
# frozen_string_literal: true
2023-12-08 17:28:45 +01:00
module Twenty
2024-04-27 04:55:33 +02:00
extend Module.new {
2024-04-27 06:31:01 +02:00
require "tmpdir"
require "fileutils"
2024-04-27 05:46:24 +02:00
extend self
2024-04-27 04:55:33 +02:00
extend FileUtils
##
# @return [String]
# Returns the path for the default SQLite database
def default_database
@default_database ||= File.join(datadir, "database.sqlite")
end
##
# @return [String]
# Returns the directory where twenty stores data
def datadir
File.join(Dir.home, ".local", "share", "twenty")
end
##
# @return [String]
# Returns the directory where twenty stores temporary data
def tmpdir
File.join(Dir.tmpdir, "twenty")
end
##
# @return [String]
# Returns the path to a PID file
def pid
File.join(tmpdir, "server.pid")
end
mkdir_p(datadir)
mkdir_p(tmpdir)
}
##
2024-04-27 04:44:20 +02:00
# Establishes a database connection
#
# @param [String] path
2024-04-27 04:44:20 +02:00
# The path to a SQLite database
#
# @return [void]
def self.establish_connection(path:)
2024-03-28 06:22:08 +01:00
@connection = Sequel.connect(
adapter: "sqlite",
database: path
)
end
2024-04-27 04:44:20 +02:00
##
# @return [Sequel::Database::SQLite]
# Returns the connection to a database
2024-03-28 06:22:08 +01:00
def self.connection
establish_connection unless @connection
@connection
end
2024-04-27 06:31:01 +02:00
require "sequel"
2024-04-27 07:25:12 +02:00
require_relative "server/mixin"
2024-04-27 06:31:01 +02:00
require_relative "server/migration"
require_relative "server/graphql"
require_relative "server/rack"
2023-12-08 17:28:45 +01:00
end