certichain

Blockchain built from scratch for verifying document's legitimacy.
Log | Files | Refs | README | LICENSE

commit 8f2e3a9374d86619b53d8ba30832784514edc7d7
parent 7aeff6d636c45878eb6af86733b12e883b8a8bcf
Author: Shivakumar <[email protected]>
Date:   Sun,  2 Aug 2026 00:43:36 +0530

feat(api): add cmd/node/main to run server

Signed-off-by: Shivakumar <[email protected]>

Diffstat:
Acmd/node/main.go | 54++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+), 0 deletions(-)

diff --git a/cmd/node/main.go b/cmd/node/main.go @@ -0,0 +1,54 @@ +// Copyright 2026 Shivakumar (Certichain) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "log" + "net/http" + + "certichain/api" + "certichain/internal/blockchain" + "certichain/internal/storage" +) + +const ( + dataPath = "./data" + addr = ":8080" +) + +func main() { + store, err := storage.NewBadgerStore(dataPath) + if err != nil { + log.Fatal(err) + } + defer store.Close() + + bc, err := blockchain.New(store) + if err != nil { + log.Fatal(err) + } + defer bc.Close() + + deps := api.Deps{ + Blockchain: bc, + } + + srv := api.NewServer(addr, deps) + + log.Printf("certichain node listening on %s", addr) + if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed { + log.Fatalf("server error: %v", err) + } +}