Skip to content

feat: use WebStorage API for internal data #22

@maximousblk

Description

@maximousblk

🚀 Feature

All the info that should not be view or edited by the user should be stored in localstorage.

Motivation

Deno added support for WebStorage API

blog post: https://deno.com/blog/v1.10#support-for-web-storage-api

This would also make the code a bit cleaner since we won't have to poke the environment variables to find the home directory just to get the user's access token.

pr: denoland/deno#7819

Implementation

The user would define the location during install like so:

deno install -qA --unstable --location https://nest.land https://nest.land/-/nest/nest.ts

and used like so:

// Add new user (nest login)
addUser(username: string, token: string) {
  const users: Users = JSON.parse(localStorage.getItem('users'));
	  
  users[username] = { token }

  localStorage.setItem('users', JSON.stringify(users);
}

addUser('maximousblk', 'NEST_6FF4C8F4374F46C5A5928AFE85C2354EA37AED00')


// Change active user (nest switch)
setActiveUser(username: string) {
  localStorage.setItem('activeUser', username);
}

setActiveUser('maximousblk')

Alternatives

n/a

Additional context

n/a

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions